Kaynağa Gözat

change graph title

Mohidul Islam 5 yıl önce
ebeveyn
işleme
2cf2ce3388
2 değiştirilmiş dosya ile 6 ekleme ve 5 silme
  1. 3 3
      analytics/templates/charts.html
  2. 3 2
      analytics/utils.py

+ 3 - 3
analytics/templates/charts.html

@@ -100,7 +100,7 @@
                     title: {
                         display: true,
                         fontSize: 20,
-                        text: 'Total Star Rating  - ' + ' ' + location_name
+                        text: "One Year's Total Star Rating  - " + ' ' + location_name
                     }
                 }
             });
@@ -134,7 +134,7 @@
                     title: {
                         display: true,
                         fontSize: 16,
-                        text: 'Total Review  - ' + ' ' +location_name
+                        text: "One Year's Total Review  - " + ' ' +location_name
                     }
                 }
             });
@@ -157,7 +157,7 @@
                     title: {
                         display: true,
                         fontSize: 16,
-                        text: 'Last '+time_interval+'  - ' + ' ' + location_name
+                        text: 'This '+time_interval+'  - ' + ' ' + location_name
                     }
                 }
             });

+ 3 - 2
analytics/utils.py

@@ -4,7 +4,8 @@ from django.db.models import Count
 
 
 def last_data(date, location_id):
-    res = Review.objects.filter(create_time__gte=date, location_id=location_id).values('star_rating').annotate(total=Count('star_rating')).order_by('star_rating')
+    res = Review.objects.filter(create_time__gte=date, location_id=location_id).values('star_rating')\
+        .annotate(total=Count('star_rating')).order_by('star_rating')
     ratings = [0] * 5
     for r in res:
         ratings[r.get('star_rating')-1] = r.get('total')
@@ -58,7 +59,7 @@ def get_review_count_by_month(location_id):
 def get_review_count_by_week(location_id):
     now = timezone.now()
     day = 6 - now.weekday()
-    first_day_week = now - timezone.timedelta(days=now.weekday()+1)
+    first_day_week = now - timezone.timedelta(days=(now.weekday()+1))
     this_week = last_data(first_day_week, location_id)
     sql = f'''
     SELECT review_id, WEEK(create_time) as week, COUNT(review_id) as total_review