123456789101112131415161718192021 |
- from django.db.models import Count
- from django.utils import timezone
- from .models import YelpReview
- from name_extractor.utils import get_all_people_names
- def get_staff_names(reviews):
- all_names = []
- for review in reviews:
- names = list(get_all_people_names(review.comment))
- all_names.extend(names)
- return list(set(all_names))
- def get_weekly_summary(location_id):
- date = timezone.now() - timezone.timedelta(days=100)
- reviews = YelpReview.objects.filter(location__location_id=location_id, date_posted__gte=date)
- rating = reviews.values('rating').annotate(total=Count('rating'))
- names = get_staff_names(reviews)
- return reviews, rating, names
|