Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow different analysis json format #278

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions recipes/VideoBotsStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
TruncYear,
Concat,
)
from django.db.models import Count, Avg
from django.db.models import Count, Avg, Q

ID_COLUMNS = [
"conversation__fb_page_id",
Expand Down Expand Up @@ -543,6 +543,7 @@ def calculate_stats_binned_by_time(
df["Msgs_per_user"] = df["Messages_Sent"] / df["Senders"]
df.fillna(0, inplace=True)
df = df.round(0).astype("int32", errors="ignore")
df = df.sort_values(by=["date"], ascending=True).reset_index()
return df

def plot_graphs(self, view, df):
Expand Down Expand Up @@ -806,8 +807,6 @@ def get_tabular_data(
neg_feedbacks: FeedbackQuerySet = Feedback.objects.filter(
message__conversation__bot_integration=bi,
rating=Feedback.Rating.RATING_THUMBS_DOWN,
created_at__date__gte=start_date,
created_at__date__lte=end_date,
) # type: ignore
if start_date and end_date:
neg_feedbacks = neg_feedbacks.filter(
Expand All @@ -818,10 +817,9 @@ def get_tabular_data(
df["Bot"] = bi.name
elif details == "Answered Successfully":
successful_messages: MessageQuerySet = Message.objects.filter(
Q(analysis_result__contains={"Answered": True})
| Q(analysis_result__contains={"assistant": {"answer": "Found"}}),
conversation__bot_integration=bi,
analysis_result__contains={"Answered": True},
created_at__date__gte=start_date,
created_at__date__lte=end_date,
) # type: ignore
if start_date and end_date:
successful_messages = successful_messages.filter(
Expand All @@ -832,10 +830,9 @@ def get_tabular_data(
df["Bot"] = bi.name
elif details == "Answered Unsuccessfully":
unsuccessful_messages: MessageQuerySet = Message.objects.filter(
Q(analysis_result__contains={"Answered": False})
| Q(analysis_result__contains={"assistant": {"answer": "Missing"}}),
conversation__bot_integration=bi,
analysis_result__contains={"Answered": False},
created_at__date__gte=start_date,
created_at__date__lte=end_date,
) # type: ignore
if start_date and end_date:
unsuccessful_messages = unsuccessful_messages.filter(
Expand Down
Loading