fix: censures/hesitations returning only the first reasons

Closes #59
pull/61/head
db0 2023-11-05 22:55:04 +01:00
parent 364deba6b7
commit 97f4312a5e
2 changed files with 8 additions and 8 deletions

View File

@ -162,11 +162,11 @@ class Censures(Resource):
censures = database.get_all_censure_reasons_for_censured_id(instance.id, [c.id for c in instances]) censures = database.get_all_censure_reasons_for_censured_id(instance.id, [c.id for c in instances])
rebuttals = database.get_all_rebuttals_from_source_instance_id(instance.id,[c.id for c in instances]) rebuttals = database.get_all_rebuttals_from_source_instance_id(instance.id,[c.id for c in instances])
for c_instance in instances: for c_instance in instances:
censures = [c for c in censures if c.reason is not None and c.censuring_id == c_instance.id] censures_filtered = [c for c in censures if c.reason is not None and c.censuring_id == c_instance.id]
c_instance_details = c_instance.get_details() c_instance_details = c_instance.get_details()
if len(censures) > 0: if len(censures_filtered) > 0:
c_instance_details["censure_reasons"] = [censure.reason for censure in censures] c_instance_details["censure_reasons"] = [censure.reason for censure in censures_filtered]
c_instance_details["censure_evidence"] = [censure.evidence for censure in censures if censure.evidence is not None] c_instance_details["censure_evidence"] = [censure.evidence for censure in censures_filtered if censure.evidence is not None]
rebuttals = [r.rebuttal for r in rebuttals if r.target_id == c_instance.id] rebuttals = [r.rebuttal for r in rebuttals if r.target_id == c_instance.id]
if len(rebuttals) > 0 and not database.instance_has_flag(c_instance.id,enums.InstanceFlags.MUTED): if len(rebuttals) > 0 and not database.instance_has_flag(c_instance.id,enums.InstanceFlags.MUTED):
c_instance_details["rebuttal"] = rebuttals c_instance_details["rebuttal"] = rebuttals

View File

@ -147,11 +147,11 @@ class Hesitations(Resource):
hesitations = database.get_all_hesitation_reasons_for_dubious_id(instance.id, [c.id for c in instances]) hesitations = database.get_all_hesitation_reasons_for_dubious_id(instance.id, [c.id for c in instances])
rebuttals = database.get_all_rebuttals_from_source_instance_id(instance.id,[c.id for c in instances]) rebuttals = database.get_all_rebuttals_from_source_instance_id(instance.id,[c.id for c in instances])
for c_instance in instances: for c_instance in instances:
hesitations = [c for c in hesitations if c.reason is not None and c.hesitant_id == c_instance.id] hesitations_filtered = [c for c in hesitations if c.reason is not None and c.hesitant_id == c_instance.id]
c_instance_details = c_instance.get_details() c_instance_details = c_instance.get_details()
if len(hesitations) > 0: if len(hesitations_filtered) > 0:
c_instance_details["hesitation_reasons"] = [hesitation.reason for hesitation in hesitations] c_instance_details["hesitation_reasons"] = [hesitation.reason for hesitation in hesitations_filtered]
c_instance_details["hesitation_evidence"] = [hesitation.evidence for hesitation in hesitations if hesitation.evidence is not None] c_instance_details["hesitation_evidence"] = [hesitation.evidence for hesitation in hesitations_filtered if hesitation.evidence is not None]
c_instance_details["rebuttal"] = [r.rebuttal for r in rebuttals if r.target_id == c_instance.id] c_instance_details["rebuttal"] = [r.rebuttal for r in rebuttals if r.target_id == c_instance.id]
instance_details.append(c_instance_details) instance_details.append(c_instance_details)
if self.args.csv: if self.args.csv: