Gabriel Sabau commited on
Commit ·
8ab5552
1
Parent(s): 7443b9e
fix: Refactor compute_offer function to exclude offers by offer_id
Browse files- utils/gradio_utils.py +5 -4
utils/gradio_utils.py
CHANGED
|
@@ -258,14 +258,16 @@ def compute_offer(csv_file, days_lookback, min_sent, domain, team, offer_type, x
|
|
| 258 |
else:
|
| 259 |
team_members = [] # All
|
| 260 |
|
| 261 |
-
cols = ['Campanie', 'Oferta', 'Nume', 'Server', 'User',
|
| 262 |
'Lista Custom', 'Data', 'HClicks', 'Clicks', 'Unscribers', 'Openers',
|
| 263 |
'Click Open', 'Leads', 'CLike', 'Complains', 'Traps', 'Send', 'ECPM', 'Comision', 'Domeniu']
|
| 264 |
|
|
|
|
|
|
|
| 265 |
exclude_list = df_all[(df_all['Data'] > (pd.Timestamp('now') - pd.Timedelta(days=days_lookback))) \
|
| 266 |
& (df_all['Domeniu'] == domain)\
|
| 267 |
-
& (df_all['User'].isin(team_members))]['
|
| 268 |
-
df_all = df_all[~df_all['
|
| 269 |
|
| 270 |
df_all = df_all[df_all['Send'] > int(min_sent)]
|
| 271 |
df_all = df_all[cols]
|
|
@@ -322,7 +324,6 @@ def compute_offer(csv_file, days_lookback, min_sent, domain, team, offer_type, x
|
|
| 322 |
final_df['ECPM'] = final_df['ECPM'].round(2).astype(float)
|
| 323 |
final_df.reset_index(inplace=True)
|
| 324 |
elif offer_type == "Offers - IDs only":
|
| 325 |
-
df_all['offer_id'] = df_all['Nume'].str.extract(r'(\d{3,4}$)')
|
| 326 |
|
| 327 |
final_df = df_all.groupby(["offer_id"])\
|
| 328 |
.agg( times_sent=('offer_id', 'count'), send_avg=('Send', 'mean'), total_sent=('Send', 'sum'),\
|
|
|
|
| 258 |
else:
|
| 259 |
team_members = [] # All
|
| 260 |
|
| 261 |
+
cols = ['Campanie', 'Oferta', 'Nume', 'Server', 'User', 'offer_id',
|
| 262 |
'Lista Custom', 'Data', 'HClicks', 'Clicks', 'Unscribers', 'Openers',
|
| 263 |
'Click Open', 'Leads', 'CLike', 'Complains', 'Traps', 'Send', 'ECPM', 'Comision', 'Domeniu']
|
| 264 |
|
| 265 |
+
df_all['offer_id'] = df_all['Nume'].str.extract(r'(\d{3,4}$)')
|
| 266 |
+
|
| 267 |
exclude_list = df_all[(df_all['Data'] > (pd.Timestamp('now') - pd.Timedelta(days=days_lookback))) \
|
| 268 |
& (df_all['Domeniu'] == domain)\
|
| 269 |
+
& (df_all['User'].isin(team_members))]['offer_id'].unique()
|
| 270 |
+
df_all = df_all[~df_all['offer_id'].isin(exclude_list)]
|
| 271 |
|
| 272 |
df_all = df_all[df_all['Send'] > int(min_sent)]
|
| 273 |
df_all = df_all[cols]
|
|
|
|
| 324 |
final_df['ECPM'] = final_df['ECPM'].round(2).astype(float)
|
| 325 |
final_df.reset_index(inplace=True)
|
| 326 |
elif offer_type == "Offers - IDs only":
|
|
|
|
| 327 |
|
| 328 |
final_df = df_all.groupby(["offer_id"])\
|
| 329 |
.agg( times_sent=('offer_id', 'count'), send_avg=('Send', 'mean'), total_sent=('Send', 'sum'),\
|