|
@@ -32,19 +32,33 @@ def get_google_review_report(location_id):
|
|
|
|
|
|
reviews = Review.objects.all()
|
|
reviews = Review.objects.all()
|
|
|
|
|
|
- this_month = reviews.filter(
|
|
|
|
|
|
+ this_month_pos = reviews.filter(
|
|
location_id=location_id,
|
|
location_id=location_id,
|
|
- create_time__range=(beginning_of_month, now)
|
|
|
|
|
|
+ create_time__range=(beginning_of_month, now),
|
|
|
|
+ star_rating__gte=4
|
|
|
|
+ ).count()
|
|
|
|
+ this_month_neg = reviews.filter(
|
|
|
|
+ location_id=location_id,
|
|
|
|
+ create_time__range=(beginning_of_month, now),
|
|
|
|
+ star_rating__lte=3
|
|
).count()
|
|
).count()
|
|
|
|
|
|
- last_month = reviews.filter(
|
|
|
|
|
|
+ last_month_pos = reviews.filter(
|
|
location_id=location_id,
|
|
location_id=location_id,
|
|
- create_time__range=(beginning_of_last_month, beginning_of_month)
|
|
|
|
|
|
+ create_time__range=(beginning_of_last_month, beginning_of_month),
|
|
|
|
+ star_rating__gte=4
|
|
|
|
+ ).count()
|
|
|
|
+ last_month_neg = reviews.filter(
|
|
|
|
+ location_id=location_id,
|
|
|
|
+ create_time__range=(beginning_of_last_month, beginning_of_month),
|
|
|
|
+ star_rating__lt=4
|
|
).count()
|
|
).count()
|
|
|
|
|
|
return {
|
|
return {
|
|
- 'this_month': this_month,
|
|
|
|
- 'last_month': last_month
|
|
|
|
|
|
+ 'this_month_pos': this_month_pos,
|
|
|
|
+ 'last_month_pos': last_month_pos,
|
|
|
|
+ 'this_month_neg': this_month_neg,
|
|
|
|
+ 'last_month_neg': last_month_neg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -55,19 +69,35 @@ def get_facebook_report(location_id):
|
|
|
|
|
|
reviews = FacebookReview.objects.all()
|
|
reviews = FacebookReview.objects.all()
|
|
|
|
|
|
- this_month = reviews.filter(
|
|
|
|
|
|
+ this_month_pos = reviews.filter(
|
|
|
|
+ page__location_id=location_id,
|
|
|
|
+ create_time__range=(beginning_of_month, now),
|
|
|
|
+ recommendation_type=True
|
|
|
|
+ ).count()
|
|
|
|
+
|
|
|
|
+ last_month_pos = reviews.filter(
|
|
page__location_id=location_id,
|
|
page__location_id=location_id,
|
|
- create_time__range=(beginning_of_month, now)
|
|
|
|
|
|
+ create_time__range=(beginning_of_last_month, beginning_of_month),
|
|
|
|
+ recommendation_type=True
|
|
|
|
+ ).count()
|
|
|
|
+
|
|
|
|
+ this_month_neg = reviews.filter(
|
|
|
|
+ page__location_id=location_id,
|
|
|
|
+ create_time__range=(beginning_of_month, now),
|
|
|
|
+ recommendation_type=False
|
|
).count()
|
|
).count()
|
|
|
|
|
|
- last_month = reviews.filter(
|
|
|
|
|
|
+ last_month_neg = reviews.filter(
|
|
page__location_id=location_id,
|
|
page__location_id=location_id,
|
|
- create_time__range=(beginning_of_last_month, beginning_of_month)
|
|
|
|
|
|
+ create_time__range=(beginning_of_last_month, beginning_of_month),
|
|
|
|
+ recommendation_type=False
|
|
).count()
|
|
).count()
|
|
|
|
|
|
return {
|
|
return {
|
|
- 'this_month': this_month,
|
|
|
|
- 'last_month': last_month
|
|
|
|
|
|
+ 'this_month_pos': this_month_pos,
|
|
|
|
+ 'last_month_pos': last_month_pos,
|
|
|
|
+ 'this_month_neg': this_month_neg,
|
|
|
|
+ 'last_month_neg': last_month_neg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|