From 9bf73d1cf4cfcf33b5b7b9f3fba27674f20b96d0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 May 2025 11:11:09 +0100 Subject: [PATCH] Avoid division by zero --- relationships.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/relationships.py b/relationships.py index 2c556b001..a0fdaae39 100644 --- a/relationships.py +++ b/relationships.py @@ -72,7 +72,7 @@ def get_moved_accounts(base_dir: str, nickname: str, domain: str, def get_moved_feed(base_dir: str, domain: str, port: int, path: str, http_prefix: str, authorized: bool, - follows_per_page=12) -> {}: + follows_per_page: int = 12) -> {}: """Returns the moved accounts feed from GET requests. """ # Don't show moved accounts to non-authorized viewers @@ -190,7 +190,9 @@ def get_moved_feed(base_dir: str, domain: str, port: int, path: str, page_ctr = 0 curr_page += 1 following['totalItems'] = total_ctr - last_page = int(total_ctr / follows_per_page) + last_page = 1 + if follows_per_page > 0: + last_page = int(total_ctr / follows_per_page) last_page = max(last_page, 1) if next_page_number > last_page: following['next'] = \ @@ -497,7 +499,9 @@ def get_inactive_feed(base_dir: str, domain: str, port: int, path: str, page_ctr = 0 curr_page += 1 following['totalItems'] = total_ctr - last_page = int(total_ctr / follows_per_page) + last_page = 1 + if follows_per_page > 0: + last_page = int(total_ctr / follows_per_page) last_page = max(last_page, 1) if next_page_number > last_page: following['next'] = \