From 07778667553a981219d92e0454ffeb1479f10ca9 Mon Sep 17 00:00:00 2001 From: Saliou Diallo Date: Fri, 19 Apr 2024 11:42:51 -0400 Subject: [PATCH] Update cooldown days in response (#8160) Co-authored-by: Saliou Diallo --- packages/discovery-provider/src/api/v1/models/users.py | 1 + packages/discovery-provider/src/queries/get_challenges.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/discovery-provider/src/api/v1/models/users.py b/packages/discovery-provider/src/api/v1/models/users.py index 5fd44d13e47..ad1dd3cb35b 100644 --- a/packages/discovery-provider/src/api/v1/models/users.py +++ b/packages/discovery-provider/src/api/v1/models/users.py @@ -120,6 +120,7 @@ "challenge_type": fields.String(required=True), "amount": fields.String(required=True), "disbursed_amount": fields.Integer(required=True), + "cooldown_days": fields.Integer(), "metadata": fields.Raw(required=True), }, ) diff --git a/packages/discovery-provider/src/queries/get_challenges.py b/packages/discovery-provider/src/queries/get_challenges.py index 5a0b6e51f42..6617497cff9 100644 --- a/packages/discovery-provider/src/queries/get_challenges.py +++ b/packages/discovery-provider/src/queries/get_challenges.py @@ -73,7 +73,7 @@ def rollup_aggregates( "is_disbursed": False, # This doesn't indicate anything for aggregate challenges "amount": parent_challenge.amount, "disbursed_amount": get_disbursed_amount(disbursements), - "cooldown_days": parent_challenge.cooldown_days, + "cooldown_days": parent_challenge.cooldown_days or 0, "metadata": {}, } return response_dict @@ -97,7 +97,7 @@ def to_challenge_response( "is_disbursed": disbursements is not None and len(disbursements) > 0, "amount": challenge.amount, "disbursed_amount": get_disbursed_amount(disbursements), - "cooldown_days": challenge.cooldown_days, + "cooldown_days": challenge.cooldown_days or 0, "metadata": metadata, } @@ -119,7 +119,7 @@ def create_empty_user_challenges( "is_disbursed": False, "amount": challenge.amount, "disbursed_amount": 0, - "cooldown_days": challenge.cooldown_days, + "cooldown_days": challenge.cooldown_days or 0, "metadata": metadatas[i], } user_challenges.append(user_challenge)