Skip to content

Commit

Permalink
Aircall: fix "calls" datasource
Browse files Browse the repository at this point in the history
Replace null values with the label 'NO TEAMS' in the column "team" of the
"calls" dataset (in coherence with what we do for the "users" dataset).
  • Loading branch information
vdestraitt committed Apr 23, 2020
1 parent 3d16583 commit 56d8e46
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/aircall/test_aircall.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test__retrieve_data_no_teams_case(con, mocker):
# must have calls and still have a team column even if everything is NaN
assert run_fetches_mock.call_count == 1
assert df.shape == (10, 11)
assert df['team'].isna().any()
assert df['team'].isin(['NO TEAM']).all()


def test__retrieve_tags_from_fetch(con, mocker):
Expand Down
2 changes: 1 addition & 1 deletion tests/aircall/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_build_calls_df():
fake_list_of_data_3 = [empty_df, empty_var_df, calls_df]
df_3 = build_df('calls', fake_list_of_data_3)
assert df_3.shape == (10, 11)
assert df_3['team'].isna().all()
assert df_3['team'].isin(['NO TEAM']).all()

# empty arrays
fake_list_of_data_4 = [empty_df, empty_var_df, empty_var_df]
Expand Down
1 change: 1 addition & 0 deletions toucan_connectors/aircall/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def build_df(dataset: str, list_of_data: List[dict]) -> pd.DataFrame:
answered_at=lambda t: pd.to_datetime(t['answered_at'], unit='s'),
ended_at=lambda t: pd.to_datetime(t['ended_at'], unit='s'),
day=lambda t: t['ended_at'].astype(str).str[:10],
team=lambda x: x['team'].replace({np.NaN: 'NO TEAM'}),
)
return total_df[COLUMN_DICTIONARY[dataset]]

Expand Down

0 comments on commit 56d8e46

Please sign in to comment.