fix: include null reasons in censures list

pull/20/head
db0 2023-09-08 14:05:33 +02:00
parent 645503d0fe
commit 78b1ebfa91
2 changed files with 3 additions and 2 deletions

View File

@ -27,8 +27,9 @@ class CensuresGiven(Resource):
instance_details = []
for c_instance in database.get_all_censured_instances_by_censuring_id([instance.id for instance in instances]):
censures = database.get_all_censure_reasons_for_censured_id(c_instance.id, [instance.id for instance in instances])
c_instance_details = c_instance.get_details()
censure_count = len(censures)
censures = [c for c in censures if c.reason is not None]
c_instance_details = c_instance.get_details()
skip_instance = False
if self.args.reasons_csv:
reasons_filter = [r.strip().lower() for r in self.args.reasons_csv.split(',')]
@ -73,6 +74,7 @@ class Censures(Resource):
instance_details = []
for c_instance in database.get_all_censuring_instances_by_censured_id(instance.id):
censures = database.get_all_censure_reasons_for_censured_id(instance.id, [c_instance.id])
censures = [c for c in censures if c.reason is not None]
c_instance_details = c_instance.get_details()
if len(censures) > 0:
c_instance_details["censure_reasons"] = [censure.reason for censure in censures]

View File

@ -96,7 +96,6 @@ def get_all_censure_reasons_for_censured_id(censured_id, censuring_ids):
and_(
Censure.censured_id == censured_id,
Censure.censuring_id.in_(censuring_ids),
Censure.reason != None
)
).with_entities(Censure.reason)
return query.all()