Skip to content

Commit

Permalink
add reg count to list details
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheo committed Oct 7, 2024
1 parent 3a4a31d commit 5e3f19a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion indexer_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,15 @@ 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"]})
insert_data.append(
{
"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),
Expand Down
5 changes: 5 additions & 0 deletions lists/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Meta:
"name",
"description",
"upvotes",
"registrations_count",
"cover_image_url",
"admin_only_registrations",
"default_registration_status",
Expand All @@ -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
Expand Down

0 comments on commit 5e3f19a

Please sign in to comment.