fix: missing censures when paginating

pull/61/head
db0 2023-11-10 02:04:56 +01:00
parent 97f4312a5e
commit e1b5adecd7
3 changed files with 20 additions and 3 deletions

View File

@ -25,3 +25,7 @@ def after_request(response):
etag = "Runtime Error" etag = "Runtime Error"
response.headers["ETag"] = etag response.headers["ETag"] = etag
return response return response
if args.test:
import fediseer.sandbox

View File

@ -76,7 +76,7 @@ def get_all_endorsed_instances_by_approving_id(approving_ids,page=1,limit=100):
page -= 1 page -= 1
if page < 0: if page < 0:
page = 0 page = 0
return query.offset(limit * page).limit(limit).all() return query.order_by(Instance.domain).offset(limit * page).limit(limit).all()
else: else:
return query.all() return query.all()
@ -141,7 +141,8 @@ def get_all_censured_instances_by_censuring_id(censuring_ids,page=1,limit=100):
page -= 1 page -= 1
if page < 0: if page < 0:
page = 0 page = 0
return query.offset(limit * page).limit(limit).all() logger.debug([limit * page,limit])
return query.order_by(Instance.domain).offset(limit * page).limit(limit).all()
else: else:
return query.all() return query.all()
@ -204,7 +205,7 @@ def get_all_dubious_instances_by_hesitant_id(hesitant_ids,page=1,limit=100):
page -= 1 page -= 1
if page < 0: if page < 0:
page = 0 page = 0
return query.offset(limit * page).limit(limit).all() return query.order_by(Instance.domain).offset(limit * page).limit(limit).all()
else: else:
return query.all() return query.all()

View File

@ -0,0 +1,12 @@
from fediseer.flask import OVERSEER
from fediseer.database import functions as database
from fediseer.logger import logger
import sys
# Limits test
# with OVERSEER.app_context():
# domains_list = ["lemmy.dbzer0.com","lemmy.ca","lemmy.basedcount.com","sh.itjust.works","aussie.zone","literature.cafe","lemmy.blahaj.zone","feddit.de","lemmy.myserv.one","programming.dev","lemmy.world","lemy.lol","lemm.ee","lemmy.team","infosec.pub","discuss.tchncs.de","lemmy.zip","phpc.social","discuss.online","lemmy.magnor.ovh","lemmynsfw.com","lemmyf.uk","lemmy.cwagner.me","startrek.website","lemdro.id"]
# instances = database.find_multiple_instance_by_domains(domains_list)
# censures = database.get_all_censured_instances_by_censuring_id(
# censuring_ids = [instance.id for instance in instances], limit=1000)
sys.exit()