|
@@ -13,7 +13,7 @@ def get_weeks(_year, _week):
|
|
return this_year
|
|
return this_year
|
|
|
|
|
|
|
|
|
|
-def weekly_positive_review_count():
|
|
|
|
|
|
+def weekly_google_positive_review_count():
|
|
sql = f'''
|
|
sql = f'''
|
|
select
|
|
select
|
|
week(create_time) as week,
|
|
week(create_time) as week,
|
|
@@ -44,7 +44,7 @@ def weekly_positive_review_count():
|
|
return res, location_dict.values()
|
|
return res, location_dict.values()
|
|
|
|
|
|
|
|
|
|
-def weekly_negative_review_count():
|
|
|
|
|
|
+def weekly_google_negative_review_count():
|
|
sql = f'''
|
|
sql = f'''
|
|
select
|
|
select
|
|
week(create_time) as week,
|
|
week(create_time) as week,
|
|
@@ -90,7 +90,7 @@ def weekly_facebook_positive_review_count():
|
|
ORDER BY week DESC;
|
|
ORDER BY week DESC;
|
|
'''
|
|
'''
|
|
now = timezone.now()
|
|
now = timezone.now()
|
|
- location_dict = dict(Location.objects.values_list('location_id', 'care_name'))
|
|
|
|
|
|
+ location_dict = dict(Location.objects.values_list('facebookpage__id', 'care_name'))
|
|
with connection.cursor() as cursor:
|
|
with connection.cursor() as cursor:
|
|
cursor.execute(sql)
|
|
cursor.execute(sql)
|
|
rows = cursor.fetchall()
|
|
rows = cursor.fetchall()
|
|
@@ -106,22 +106,22 @@ def weekly_facebook_positive_review_count():
|
|
return res, location_dict.values()
|
|
return res, location_dict.values()
|
|
|
|
|
|
|
|
|
|
-def weekly_negative_review_count():
|
|
|
|
|
|
+def weekly_facebook_negative_review_count():
|
|
sql = f'''
|
|
sql = f'''
|
|
select
|
|
select
|
|
week(create_time) as week,
|
|
week(create_time) as week,
|
|
year(create_time) as year,
|
|
year(create_time) as year,
|
|
- location_id,
|
|
|
|
|
|
+ page_id,
|
|
count(*) as rev_count
|
|
count(*) as rev_count
|
|
- from review_review
|
|
|
|
|
|
+ from facebook_app_facebookreview
|
|
where
|
|
where
|
|
create_time >= (curdate() - interval 10 week) and
|
|
create_time >= (curdate() - interval 10 week) and
|
|
- star_rating <= 3
|
|
|
|
- group by week(create_time), location_id
|
|
|
|
|
|
+ recommendation_type = false
|
|
|
|
+ group by week(create_time), page_id
|
|
ORDER BY week DESC;
|
|
ORDER BY week DESC;
|
|
'''
|
|
'''
|
|
now = timezone.now()
|
|
now = timezone.now()
|
|
- location_dict = dict(Location.objects.values_list('location_id', 'care_name'))
|
|
|
|
|
|
+ location_dict = dict(Location.objects.values_list('facebookpage__id', 'care_name'))
|
|
with connection.cursor() as cursor:
|
|
with connection.cursor() as cursor:
|
|
cursor.execute(sql)
|
|
cursor.execute(sql)
|
|
rows = cursor.fetchall()
|
|
rows = cursor.fetchall()
|
|
@@ -135,3 +135,17 @@ def weekly_negative_review_count():
|
|
# res[w[0]] = weeks_res
|
|
# res[w[0]] = weeks_res
|
|
res.append(weeks_res)
|
|
res.append(weeks_res)
|
|
return res
|
|
return res
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def weekly_positive_review_count():
|
|
|
|
+ X, loc = weekly_google_positive_review_count()
|
|
|
|
+ Y, loc = weekly_facebook_positive_review_count()
|
|
|
|
+ result = [[X[i][j] + Y[i][j] for j in range(len(X[0]))] for i in range(len(X))]
|
|
|
|
+ return result, loc
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def weekly_negative_review_count():
|
|
|
|
+ X = weekly_google_negative_review_count()
|
|
|
|
+ Y = weekly_facebook_negative_review_count()
|
|
|
|
+ result = [[X[i][j] + Y[i][j] for j in range(len(X[0]))] for i in range(len(X))]
|
|
|
|
+ return result
|