limit ui to showing 500 latest announces

This commit is contained in:
liamcottle 2024-08-13 23:00:42 +12:00
commit bc53516c64
2 changed files with 8 additions and 2 deletions

View file

@ -768,6 +768,7 @@ class ReticulumMeshChat:
# get query params
aspect = request.query.get("aspect", None)
limit = request.query.get("limit", None)
# build announces database query
query = database.Announce.select()
@ -776,8 +777,12 @@ class ReticulumMeshChat:
if aspect is not None:
query = query.where(database.Announce.aspect == aspect)
# get announces from database
query_results = query.order_by(database.Announce.id.asc())
# limit results
if limit is not None:
query = query.limit(limit)
# order announces latest to oldest
query_results = query.order_by(database.Announce.updated_at.desc())
# process announces
announces = []

View file

@ -143,6 +143,7 @@ export default {
const response = await window.axios.get(`/api/v1/announces`, {
params: {
aspect: "lxmf.delivery",
limit: 500, // limit ui to showing 500 latest announces
},
});