|
@@ -30,15 +30,40 @@ def predict_report(request, review_id):
|
|
|
reviews = paginator.page(1)
|
|
|
except EmptyPage:
|
|
|
reviews = paginator.page(paginator.num_pages)
|
|
|
- replies = {}
|
|
|
- for intent in intents.keys():
|
|
|
- r = CustomReply.objects.filter(reply_category=intent)
|
|
|
- filtered_replies = filter_with_last_ten_reviews(location_id, r)
|
|
|
- replies[intent] = filtered_replies
|
|
|
+ if review.star_rating == 5:
|
|
|
+ replies = {}
|
|
|
+ for intent in intents.keys():
|
|
|
+ r = CustomReply.objects.filter(reply_category=intent)
|
|
|
+ filtered_replies = filter_with_last_ten_reviews(location_id, r)
|
|
|
+ replies[intent] = filtered_replies
|
|
|
+
|
|
|
+ # ================================================================================================================================
|
|
|
+ # This is for temporary use, It will be remove in future release.
|
|
|
+ # This part of code block is used for show all reviews as intent classifier make mistake sometime.
|
|
|
+ replies2 = {}
|
|
|
+ rep_cls = {'staff', 'facility', 'kids', 'quick', 'general_review', 'open_24', 'continuous_visit'}.difference(set(intents.keys()))
|
|
|
+ for c in rep_cls:
|
|
|
+ r = CustomReply.objects.filter(reply_category=c)
|
|
|
+ filtered_replies = filter_with_last_ten_reviews(location_id, r)
|
|
|
+ replies2[c] = filtered_replies
|
|
|
+
|
|
|
+ # End of the temporary code block
|
|
|
+ # ================================================================================================================================
|
|
|
+ else:
|
|
|
+ cr = CustomReply.objects.values('reply_category').distinct()
|
|
|
+ cr_li = {c_r['reply_category'] for c_r in cr}
|
|
|
+ rep_cls = cr_li.difference({'staff', 'facility', 'kids', 'quick', 'general_review', 'open_24', 'continuous_visit', 'no_comment'})
|
|
|
+ replies = {}
|
|
|
+ replies2 = None
|
|
|
+ for c in rep_cls:
|
|
|
+ r = CustomReply.objects.filter(reply_category=c)
|
|
|
+ filtered_replies = filter_with_last_ten_reviews(location_id, r)
|
|
|
+ replies[c] = filtered_replies
|
|
|
context = {
|
|
|
'reviews': reviews,
|
|
|
'form': form,
|
|
|
'intents': intents,
|
|
|
- 'replies': replies
|
|
|
+ 'replies': replies,
|
|
|
+ 'replies2': replies2 # This context is associate with the temporary code that mentioned above.
|
|
|
}
|
|
|
return render(request, 'dashboard.html', context)
|