123456789101112 |
- from django.db.models import Count
- from django.utils import timezone
- from .models import FacebookReview
- def get_facebook_weekly_summary(location_id):
- date = timezone.now() - timezone.timedelta(days=7)
- reviews = FacebookReview.objects.filter(page__location_id=location_id, create_time__gte=date)
- rating = reviews.values('recommendation_type')\
- .annotate(total=Count('recommendation_type'))\
- .order_by('-recommendation_type')
- return reviews, rating
|