Skip to content

Commit

Permalink
Feature: Query authors and respondents #18
Browse files Browse the repository at this point in the history
- Bugfix: Duplicated counts at aggregated levels (category, stream), due to the same message potentially being matched by multiple keywords.
  • Loading branch information
joeflack4 committed Aug 29, 2022
1 parent 9c823b4 commit 872dc85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fhir_zulip_nlp/fhir_zulip_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ def create_report_users(df: pd.DataFrame) -> Tuple[pd.DataFrame, pd.DataFrame, p
for stream_id in streams:
stream_name = stream_id_name_map[str(stream_id)]
df_i = df[df['stream_id'] == stream_id]
# todo: Would they like the 0 totals as well? If so, rather than .unique(), should use `category_keywords`
categories = df_i['category'].unique()
for c in categories:
df_i2 = df_i[df_i['category'] == c]
Expand All @@ -426,7 +425,6 @@ def create_report_users(df: pd.DataFrame) -> Tuple[pd.DataFrame, pd.DataFrame, p
author_id: int = list(
df_i4[df_i4['timestamp'] == author_timestamp]['sender_id'].to_dict().values())[0]
participant_roles[author_id] = 'author'

# Populate: user_participation
for user_id, role in participant_roles.items():
row = {
Expand All @@ -453,6 +451,7 @@ def create_report_users(df: pd.DataFrame) -> Tuple[pd.DataFrame, pd.DataFrame, p
streams = list(df_i['stream'].unique())
for s in streams:
df_i2 = df_i[df_i['stream'] == s]
# TODO: Dedupe here?
role_counts: Dict[str, int] = df_i2['user.role'].value_counts().to_dict()
for role, count in role_counts.items():
row = {
Expand All @@ -467,6 +466,7 @@ def create_report_users(df: pd.DataFrame) -> Tuple[pd.DataFrame, pd.DataFrame, p
user_participation_stats.append(row)
categories = list(df_i2['category'].unique())
for c in categories:
# TODO: Dedupe here?
df_i3 = df_i2[df_i2['category'] == c]
role_counts: Dict[str, int] = df_i3['user.role'].value_counts().to_dict()
for role, count in role_counts.items():
Expand Down

0 comments on commit 872dc85

Please sign in to comment.