@@ -86,13 +86,9 @@ def get_short_description(cls, project):
8686 return project .get_short_description ()
8787
8888 def count_likes (self , project ):
89- # FIXME
90- # TODO: add caching here at least every 5 minutes, otherwise this will be heavy load
9189 return get_likes_count (project )
9290
9391 def count_views (self , project ):
94- # FIXME
95- # TODO: add caching here at least every 5 minutes, otherwise this will be heavy load
9692 return get_views_count (project )
9793
9894 def update (self , instance , validated_data ):
@@ -135,19 +131,16 @@ class Meta:
135131class ProjectListSerializer (serializers .ModelSerializer ):
136132 collaborators = serializers .SerializerMethodField (method_name = "get_collaborators" )
137133 likes_count = serializers .SerializerMethodField (method_name = "count_likes" )
134+ views_count = serializers .SerializerMethodField (method_name = "count_views" )
138135 collaborator_count = serializers .SerializerMethodField (
139136 method_name = "get_collaborator_count"
140137 )
141138 vacancies = ProjectVacancyListSerializer (many = True , read_only = True )
142- views_count = serializers .SerializerMethodField (method_name = "count_views" )
139+ short_description = serializers .SerializerMethodField ()
143140
144141 def count_views (self , project ):
145- # FIXME
146- # TODO: add caching here at least every 5 minutes, otherwise will be heavy load
147142 return get_views_count (project )
148143
149- short_description = serializers .SerializerMethodField ()
150-
151144 @classmethod
152145 def get_short_description (cls , project ):
153146 return project .get_short_description ()
@@ -185,7 +178,7 @@ class Meta:
185178 "views_count" ,
186179 ]
187180
188- read_only_fields = ["leader" , "views_count" ]
181+ read_only_fields = ["leader" , "views_count" , "likes_count" ]
189182
190183 def is_valid (self , * , raise_exception = False ):
191184 return super ().is_valid (raise_exception = raise_exception )
0 commit comments