diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bc0eb1..ae4f2e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +# 0.21.0 + +* Added rebuttals +* Improved speed of GET on /hesitations and /censures + # 0.20.1 * Allow filtering by software diff --git a/fediseer/apis/v1/censures.py b/fediseer/apis/v1/censures.py index 7922098..7b2bc11 100644 --- a/fediseer/apis/v1/censures.py +++ b/fediseer/apis/v1/censures.py @@ -154,10 +154,10 @@ class Censures(Resource): if p_instance != get_instance: continue instances.append(p_instance) + 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]) for c_instance in instances: - 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] + censures = [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() if len(censures) > 0: c_instance_details["censure_reasons"] = [censure.reason for censure in censures] diff --git a/fediseer/apis/v1/hesitations.py b/fediseer/apis/v1/hesitations.py index fad3c12..827f550 100644 --- a/fediseer/apis/v1/hesitations.py +++ b/fediseer/apis/v1/hesitations.py @@ -140,10 +140,10 @@ class Hesitations(Resource): continue instances.append(p_instance) instance_details = [] + 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]) for c_instance in instances: - hesitations = database.get_all_hesitation_reasons_for_dubious_id(instance.id, [c_instance.id]) - hesitations = [c for c in hesitations if c.reason is not None] + hesitations = [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() if len(hesitations) > 0: c_instance_details["hesitation_reasons"] = [hesitation.reason for hesitation in hesitations] diff --git a/fediseer/consts.py b/fediseer/consts.py index a37d612..8b31a4b 100644 --- a/fediseer/consts.py +++ b/fediseer/consts.py @@ -1,4 +1,4 @@ -FEDISEER_VERSION = "0.20.0" +FEDISEER_VERSION = "0.22.0" SUPPORTED_SOFTWARE = { "lemmy", "mastodon", diff --git a/fediseer/database/functions.py b/fediseer/database/functions.py index 9439a2e..784c106 100644 --- a/fediseer/database/functions.py +++ b/fediseer/database/functions.py @@ -147,6 +147,7 @@ def get_all_censure_reasons_for_censured_id(censured_id, censuring_ids): Censure.censured_id == censured_id, Censure.censuring_id.in_(censuring_ids), ).with_entities( + Censure.censuring_id, Censure.reason, Censure.evidence, ) @@ -199,6 +200,7 @@ def get_all_hesitation_reasons_for_dubious_id(dubious_id, hesitant_ids): Hesitation.dubious_id == dubious_id, Hesitation.hesitant_id.in_(hesitant_ids), ).with_entities( + Hesitation.hesitant_id, Hesitation.reason, Hesitation.evidence, )