| 260 | |
| 261 | |
| 262 | class ChatCountSerializer(serializers.Serializer): |
| 263 | chat_id = serializers.UUIDField(required=True, label=_("Conversation ID")) |
| 264 | |
| 265 | def get_query_set(self): |
| 266 | return QuerySet(ChatRecord).filter(chat_id=self.data.get('chat_id')) |
| 267 | |
| 268 | def update_chat(self): |
| 269 | self.is_valid(raise_exception=True) |
| 270 | count_chat_record = native_search(self.get_query_set(), get_file_content( |
| 271 | os.path.join(PROJECT_DIR, "apps", "application", 'sql', 'count_chat_record.sql')), with_search_one=True) |
| 272 | QuerySet(Chat).filter(id=self.data.get('chat_id')).update(star_num=count_chat_record.get('star_num', 0) or 0, |
| 273 | trample_num=count_chat_record.get('trample_num', |
| 274 | 0) or 0, |
| 275 | chat_record_count=count_chat_record.get( |
| 276 | 'chat_record_count', 0) or 0, |
| 277 | mark_sum=count_chat_record.get('mark_sum', 0) or 0) |
| 278 | return True |
| 279 | |
| 280 | |
| 281 | def get_source_display(source): |
no outgoing calls
no test coverage detected