diff --git a/indexer_app/utils.py b/indexer_app/utils.py index bc34468..e8abc95 100644 --- a/indexer_app/utils.py +++ b/indexer_app/utils.py @@ -422,6 +422,7 @@ async def handle_new_list_registration( # Prepare data for insertion project_list = [] insert_data = [] + parent_list = await List.objects.aget(on_chain_id=reg_data[0]["list_id"]) for dt in reg_data: logger.info(f"dt: {dt}") project_list.append({"chain_id":1, "id": dt["registrant_id"]}) @@ -429,7 +430,7 @@ async def handle_new_list_registration( { "id": dt["id"], "registrant_id": dt["registrant_id"], - "list_id": dt["list_id"], + "list_id": parent_list.id, "status": dt["status"], "submitted_at": datetime.fromtimestamp(dt["submitted_ms"] / 1000), "updated_at": datetime.fromtimestamp(dt["updated_ms"] / 1000), diff --git a/lists/serializers.py b/lists/serializers.py index 162b28d..486abc6 100644 --- a/lists/serializers.py +++ b/lists/serializers.py @@ -23,6 +23,7 @@ class Meta: "name", "description", "upvotes", + "registrations_count", "cover_image_url", "admin_only_registrations", "default_registration_status", @@ -33,6 +34,10 @@ class Meta: owner = AccountSerializer() admins = AccountSerializer(many=True) upvotes = ListUpvoteSerializer(many=True) + registrations_count = SerializerMethodField() + + def get_registrations_count(self, obj): + return obj.registrations.count() # def get_owner(self, obj): # return AccountSerializer(obj.owner).data