From 8b8502592aca838497435e3b561d1f58de3b579f Mon Sep 17 00:00:00 2001 From: Henrik Petersson <44243358+hnrkcode@users.noreply.github.com> Date: Thu, 29 Sep 2022 22:28:37 +0200 Subject: [PATCH 1/3] Ignore .vscode --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 539fb99..74d45c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ dist .tox -.coverage \ No newline at end of file +.coverage +.vscode \ No newline at end of file From 5e5b0fd8d2722b37bcd15719583153475ac44503 Mon Sep 17 00:00:00 2001 From: Henrik Petersson <44243358+hnrkcode@users.noreply.github.com> Date: Fri, 7 Oct 2022 18:52:06 +0200 Subject: [PATCH 2/3] Fix bug in get_total_category_pages that would sometimes result in an infinit loop --- loading_sdk/async_api/client.py | 14 ++++++++------ loading_sdk/sync_api/client.py | 8 +++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/loading_sdk/async_api/client.py b/loading_sdk/async_api/client.py index e954727..b527851 100644 --- a/loading_sdk/async_api/client.py +++ b/loading_sdk/async_api/client.py @@ -576,10 +576,8 @@ async def get_total_category_pages(self, category): working_page = current_page current_page *= 2 - # Check the page in the middle of highest known working page and - # current page until they have the same page number. while True: - page = working_page + (current_page - working_page) / 2 + page = working_page + math.floor((current_page - working_page) / 2) headers["page"] = str(page) async with session.get(url, headers=headers) as response: @@ -590,9 +588,13 @@ async def get_total_category_pages(self, category): else: current_page = page - if math.floor(current_page) == math.floor(working_page): + if current_page - 1 == working_page: break - total_pages = math.floor(working_page) + total_pages = working_page - return total_pages + return { + "code": 200, + "message": "OK", + "data": {"total_pages": total_pages}, + } diff --git a/loading_sdk/sync_api/client.py b/loading_sdk/sync_api/client.py index 241e859..1d8d4ee 100644 --- a/loading_sdk/sync_api/client.py +++ b/loading_sdk/sync_api/client.py @@ -539,10 +539,8 @@ def get_total_category_pages(self, category): working_page = current_page current_page *= 2 - # Check the page in the middle of highest known working page and - # current page until they have the same page number. while True: - page = working_page + (current_page - working_page) / 2 + page = working_page + math.floor((current_page - working_page) / 2) headers["page"] = str(page) response = requests.get(url, headers=headers, timeout=10) @@ -553,10 +551,10 @@ def get_total_category_pages(self, category): else: current_page = page - if math.floor(current_page) == math.floor(working_page): + if current_page - 1 == working_page: break - total_pages = math.floor(working_page) + total_pages = working_page return { "code": 200, From 87c5b5a0de25868fac2c1dc6b2b6e7f8660bb9be Mon Sep 17 00:00:00 2001 From: Henrik Petersson <44243358+hnrkcode@users.noreply.github.com> Date: Fri, 7 Oct 2022 18:57:41 +0200 Subject: [PATCH 3/3] Bump version to 0.4.1 --- docs/build/doctrees/environment.pickle | Bin 27526 -> 27526 bytes docs/build/html/.buildinfo | 2 +- .../html/_static/documentation_options.js | 2 +- docs/build/html/genindex.html | 2 +- docs/build/html/index.html | 2 +- docs/build/html/loading_sdk.html | 2 +- docs/build/html/modules.html | 2 +- docs/build/html/py-modindex.html | 2 +- docs/build/html/search.html | 2 +- docs/source/conf.py | 2 +- pyproject.toml | 2 +- 11 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle index c1acbdb807154b67d3ce5f0e661eb278c1a91760..9aa9c1fe38e91bed77796f6737eff83c6aa61300 100644 GIT binary patch delta 823 zcmZ{iUr19?9LIO&HkF|=NJAlwyXnSslxDNJT#afg?H{w|w!3-nwtKgEU9Qp~8d7^1 zNkQdr51S7`4;4s3aB0015|U6**^@qm6-5sUfp5Ll@9a|2Loc8EJKyj3{LVQ)ZhnR2 zSICnxA>HybvQ$gDVL{&rpzlOsK_5dwW*T2=@bj(Ns%_GzGf`n|BFRk(x>N+84FxA?gW?7 z3Qb0H?d?kbKd#(o$`jx^jPSYrDk%ZqF|Vi1By|;{BsZGhY2nV^4B8A#*@hu)H_00| zGr__j8+Xkp#f#mKl_J|Ss}!xhlLWqYWoGSZsOvSrw0)73WOv^tsiFOcv{DKB9jEcg z8x99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