from django.db import models from django.utils.translation import gettext_lazy as _ from django.conf import settings class OperationReportAbstract(models.Model): TIME_DAILY = 'daily' TIME_WEEKLY = 'weekly' TIME_MONTHLY = 'monthly' TIME_DIMENSION_CHOICES = ( (TIME_DAILY, _('daily')), (TIME_WEEKLY, _('weekly')), (TIME_MONTHLY, _('monthly')), ) sequence = models.CharField(max_length=16) # Daily sequence: {year}-{month}-{day}, example: 2021-12-01 # Weekly sequence: {year}-{weekNumber}, example: 2021-11 # Monthly sequence: {year}-{month}, example: 2021-01 report_date = models.DateField(db_index=True) time_dimension = models.CharField(max_length=8, choices=TIME_DIMENSION_CHOICES) created_at = models.DateTimeField(auto_now_add=True) class Meta: abstract = True class CommuntiyDailySummaryReport(OperationReportAbstract): new_user_count = models.IntegerField() new_topic_count = models.IntegerField() new_post_count = models.IntegerField() new_solved_count = models.IntegerField() new_company_verified_count = models.IntegerField() dau = models.IntegerField() total_topic_count = models.IntegerField() total_post_count = models.IntegerField() total_user_count = models.IntegerField() total_company_verified_count = models.IntegerField() total_company_name_count = models.IntegerField() last_30_days_active_user_count = models.IntegerField() class Meta: db_table = 'pingcap_community_daily_summary_report' unique_together = ('sequence', 'time_dimension') class AskTUGTopicSummaryReport(OperationReportAbstract): topic_total_count = models.IntegerField() topic_incre_count = models.IntegerField() post_total_count = models.IntegerField() post_incre_count = models.IntegerField() topic_author_total_count = models.IntegerField() topic_author_incre_count = models.IntegerField() post_author_total_count = models.IntegerField() post_author_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_topic_summary_report' unique_together = ('sequence', 'time_dimension') class AskTUGTopicCategoryReport(OperationReportAbstract): category_id = models.IntegerField() caterory_name = models.CharField(max_length=50) parent_category_id = models.IntegerField(null=True, blank=True) topic_total_count = models.IntegerField() topic_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_topic_category_report' unique_together = ('sequence', 'time_dimension', 'category_id') class AskTUGQATopicReport(OperationReportAbstract): topic_total_count = models.IntegerField(help_text='技术主题总数') topic_incre_count = models.IntegerField() post_total_count = models.IntegerField(help_text='技术主题回帖总数') post_incre_count = models.IntegerField() solved_topic_total_count = models.IntegerField(help_text='已解决技术主题总数') solved_topic_incre_count = models.IntegerField() solved_topic_ratio_of_total = models.DecimalField(max_digits=6, decimal_places=4, help_text='已解决技术主题占比') solved_topic_ratio_of_incre = models.DecimalField(max_digits=6, decimal_places=4) solved_topic_avg_replies_of_total = models.DecimalField(max_digits=10, decimal_places=2, help_text='已解决技术主题平均回帖数') solved_topic_avg_replies_of_incre = models.DecimalField(max_digits=10, decimal_places=2) solved_topic_avg_spend_hours_of_total = models.DecimalField(max_digits=10, decimal_places=2, help_text='已解决技术主题平均耗时') solved_topic_avg_spend_hours_of_incre = models.DecimalField(max_digits=10, decimal_places=2) ctc_solved_topic_total_count = models.IntegerField(help_text='CTC 解决的技术主题总数') ctc_solved_topic_incre_count = models.IntegerField() non_ctc_solved_topic_total_count = models.IntegerField(help_text='非 CTC 解决的技术主题总数') non_ctc_solved_topic_incre_count = models.IntegerField() moderator_solved_topic_total_count = models.IntegerField(help_text='版主解决的技术主题总数') moderator_solved_topic_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_qa_topic_report' unique_together = ('sequence', 'time_dimension') class AskTUGBlogTopicReport(OperationReportAbstract): topic_total_count = models.IntegerField() topic_incre_count = models.IntegerField() topic_author_total_count = models.IntegerField() topic_author_incre_count = models.IntegerField() topic_views_total_count = models.IntegerField() topic_views_incre_count = models.IntegerField() topic_like_total_count = models.IntegerField() topic_like_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_blog_topic_report' unique_together = ('sequence', 'time_dimension') class UserSummaryReport(OperationReportAbstract): user_total_count = models.IntegerField() user_incre_count = models.IntegerField() lv0_user_total_count = models.IntegerField(help_text='普通用户') lv0_user_incre_count = models.IntegerField() lv1_user_total_count = models.IntegerField(help_text='初级贡献者') lv1_user_incre_count = models.IntegerField() lv2_user_total_count = models.IntegerField(help_text='中级贡献者') lv2_user_incre_count = models.IntegerField() lv3_user_total_count = models.IntegerField(help_text='高级贡献者') lv3_user_incre_count = models.IntegerField() lv4_user_total_count = models.IntegerField(help_text='荣誉贡献者') lv4_user_incre_count = models.IntegerField() company_name_completed_user_total_count = models.IntegerField(help_text='公司名称提交总数') company_name_completed_user_incre_count = models.IntegerField() org_user_total_count = models.IntegerField(help_text='认证用户总数') org_user_incre_count = models.IntegerField() org_total_count = models.IntegerField(help_text='认证团队总数') org_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_user_summary_report' unique_together = ('sequence', 'time_dimension') class AskTUGUrgencyTopicReport(OperationReportAbstract): topic_total_count = models.IntegerField() topic_incre_count = models.IntegerField() solved_topic_total_count = models.IntegerField() solved_topic_incre_count = models.IntegerField() solved_topic_avg_spend_hours_of_total = models.DecimalField(max_digits=10, decimal_places=2) solved_topic_avg_spend_hours_of_incre = models.DecimalField(max_digits=10, decimal_places=2) solved_topic_avg_replies_of_total = models.DecimalField(max_digits=10, decimal_places=2) solved_topic_avg_replies_of_incre = models.DecimalField(max_digits=10, decimal_places=2) class Meta: db_table = 'pingcap_asktug_urgency_topic_report' unique_together = ('sequence', 'time_dimension') class AskTUGUrgencyTopicCategoryReport(OperationReportAbstract): category_id = models.IntegerField() caterory_name = models.CharField(max_length=50) topic_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_urgency_topic_category_report' unique_together = ('sequence', 'time_dimension', 'category_id') class AskTUGModeratorReport(OperationReportAbstract): user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) post_total_count = models.IntegerField() post_incre_count = models.IntegerField() topic_total_count = models.IntegerField() topic_incre_count = models.IntegerField() was_liked_total_count = models.IntegerField() was_liked_incre_count = models.IntegerField() solved_topic_total_count = models.IntegerField() solved_topic_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_moderator_report' unique_together = ('sequence', 'time_dimension', 'user') class AskTUGModeratorCandidateReport(OperationReportAbstract): user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) post_total_count = models.IntegerField() post_incre_count = models.IntegerField() topic_total_count = models.IntegerField() topic_incre_count = models.IntegerField() was_liked_total_count = models.IntegerField() was_liked_incre_count = models.IntegerField() solved_topic_total_count = models.IntegerField() solved_topic_incre_count = models.IntegerField() class Meta: db_table = 'pingcap_asktug_moderator_candidate_report' unique_together = ('sequence', 'time_dimension', 'user')