Skip to content

Commit d36a6e0

Browse files
authored
fix: paginate word mistakes by per_page instead of a hardcoded 100 (#721)
* fix: allow navigation to the last verse (6236) from draft editors next_ayah_translation and next_ayah_tafsir both guard with < 6235, so when the current record is verse 6235 (the second-to-last verse) the lookup is skipped and editors cannot advance to the final verse 6236. The sibling proofreading view (word_text_proofreadings/show.html.erb) correctly uses < 6236. Fix both guards to use the true total of 6236 verses. * fix: paginate word mistakes by per_page instead of a hardcoded 100 similar_words_data computed the offset and total_pages with a hardcoded page size of 100, but the query itself uses .limit(per_page) where per_page is 10 by default (max 50). With the default page size, page 2 already skipped past rows 11-100, and total_pages was wrong. Compute both from per_page so pagination matches the actual page size.
1 parent 334206a commit d36a6e0

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

app/models/draft/tafsir.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def split_ayah_grouping
292292
end
293293

294294
def next_ayah_tafsir
295-
if end_verse_id < 6235
295+
if end_verse_id < 6236
296296
Draft::Tafsir
297297
.where(resource_content_id: resource_content_id)
298298
.where("start_verse_id > ?", end_verse_id)

app/models/draft/translation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def draft_text=(val)
5959
end
6060

6161
def next_ayah_translation
62-
if verse_id < 6235
62+
if verse_id < 6236
6363
Draft::Translation
6464
.where(resource_content_id: resource_content_id)
6565
.where("verse_id > ?", verse_id)

app/presenters/word_mistakes_presenter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def similar_words_data
9191
.order('word_index ASC')
9292

9393
page = [current_page, 1].max
94-
offset = (page - 1) * 100
94+
offset = (page - 1) * per_page
9595

9696
similar_words = similar_words_query.offset(offset).limit(per_page)
9797
similar_mistakes = WordMistake
@@ -102,7 +102,7 @@ def similar_words_data
102102
)
103103
.group_by(&:word_id)
104104

105-
total_pages = (similar_words_query.count.to_f / 100).ceil
105+
total_pages = (similar_words_query.count.to_f / per_page).ceil
106106

107107
{
108108
count: similar_words_query.count,

0 commit comments

Comments
 (0)