تقسيم صفحات أحدث المواضيع عبر واجهة برمجة التطبيقات

مرحبًا بالجميع!

بشكل مشابه لـ هذا الموضوع، أبحث عن الطريقة الصحيحة لإجراء الترقيم (pagination) على نقطة النهاية /latest.json (المواضيع)، وتحديدًا معرفة ما هي الصفحة الأخيرة.

لقد توصلت إلى أنه عندما توجد نتائج أخرى يجب جلبها، تحتوي الاستجابة على \"more_topics_url\": \"/latest?page=X\" للصفحة التالية. ومع ذلك، بناءً على اختباراتي، يبدو أنه حتى عندما لا توجد نتائج أخرى، نحصل على صفحة أخرى في هذا الحقل.

هل توجد طريقة صحيحة لمعرفة متى نصل إلى الصفحة الأخيرة؟

شكرًا مقدّمًا!

I can’t reproduce this.

For example, you can request

https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1

that contains 30 topics and a more_topics_url with "/c/site-feedback/blog/l/latest?page=2".

Then you request that and get 25 more topics and a missing more_topics_url because it’s the end.

Thanks for such quick response and for checking it out!

You’re right. I was messing on my development environment on the per_page settings trying to avoid creating 30+ topics to test this, and came across this method, but changing it there seems to have the side-effect I mentioned, though returning the amount of results I set there.

Seems like passing ?per_page=X doesn’t have any effect on this endpoint (following your example: https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1&per_page=5, still returns 30 rows). Is there a proper way to adjust this setting?

Thanks again in advance!

هل حلّ أحد هذه المشكلة؟

سيكون الأمر مثيرًا للاهتمام أيضًا في ما يتعلق بـ per_page.