Skip to content

Commit

Permalink
chore: add followers count to a project
Browse files Browse the repository at this point in the history
  • Loading branch information
khalifan-kfan committed Jul 30, 2024
1 parent a2bab83 commit 8e42158
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/schemas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from app.models.app import App
from flask_jwt_extended import get_jwt_identity
from app.models.user import User
from app.models.project_users import ProjectFollowers



class ProjectListSchema(Schema):
Expand Down Expand Up @@ -59,6 +61,7 @@ class ProjectSchema(Schema):
disabled = fields.Boolean(dump_only=True)
admin_disabled = fields.Boolean(dump_only=True)
prometheus_url = fields.Method("get_prometheus_url", dump_only=True)
followers_count = fields.Method("get_followers_count", dump_only=True)
is_following = fields.Method("get_is_following", dump_only=True)
is_public = fields.Boolean()
tags = fields.Nested("TagsProjectsSchema", many=True, dump_only=True)
Expand All @@ -79,3 +82,6 @@ def get_apps_count(self, obj):

def get_prometheus_url(self, obj):
return obj.cluster.prometheus_url

def get_followers_count(self, obj):
return ProjectFollowers.count(project_id=obj.id)

0 comments on commit 8e42158

Please sign in to comment.