Skip to content

Comments

Fix pagination bug causing scenes to be skipped when count < per_page#673

Open
rustyinfinity wants to merge 1 commit intostashapp:mainfrom
rustyinfinity:main
Open

Fix pagination bug causing scenes to be skipped when count < per_page#673
rustyinfinity wants to merge 1 commit intostashapp:mainfrom
rustyinfinity:main

Conversation

@rustyinfinity
Copy link

Description

Fixed a pagination bug in processAll() where scenes were never processed when the total scene count was less than per_page (100)

Problem

The loop used integer floor division to calculate the number of pages:

for r in range(1, int(count / per_page) + 1):

When count < per_page (e.g. 4 scenes, per_page=100):

int(4 / 100) + 1 = 0 + 1 = 1
range(1, 1) is empty — the loop never executes
No scenes are fetched or processed

Fix

Use math.ceil instead of floor division so the loop always runs at least once when there are scenes to process:

for r in range(1, math.ceil(count / per_page) + 1):

So if scenes = 4 and per_page = 100

4/100 = 0.4 then math.ceil -> 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant