12345678910 |
- from django.db.models import Count
- from django.utils import timezone
- from .models import YelpReview
- def get_weekly_summary(location_id):
- date = timezone.now() - timezone.timedelta(days=7)
- reviews = YelpReview.objects.filter(location__location_id=location_id, date_posted__gte=date)
- rating = reviews.values('rating').annotate(total=Count('rating')).order_by('-rating')
- return reviews, rating
|