Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,32 +107,30 @@ def update_assignments(assignments_df, creators_df):
|
|
| 107 |
except Exception as e:
|
| 108 |
return f"Error updating assignments: {e}", None
|
| 109 |
|
| 110 |
-
def generate_full_schedule(
|
| 111 |
try:
|
| 112 |
-
#
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
print(f"DEBUG: Chatter File {idx + 1} Columns:", chatter_df.columns)
|
| 124 |
|
| 125 |
-
|
| 126 |
-
if "Creator" in creators_data.columns:
|
| 127 |
-
creators_data.rename(columns={"Creator": "Account"}, inplace=True)
|
| 128 |
|
| 129 |
-
# Validate
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
return f"Error: Creators file must contain the columns {required_creator_columns}."
|
| 133 |
|
| 134 |
-
#
|
|
|
|
| 135 |
full_schedule = generate_schedule(chatter_files, creators_data)
|
|
|
|
| 136 |
return full_schedule
|
| 137 |
except Exception as e:
|
| 138 |
return f"Error generating schedule: {e}"
|
|
|
|
| 107 |
except Exception as e:
|
| 108 |
return f"Error updating assignments: {e}", None
|
| 109 |
|
| 110 |
+
def generate_full_schedule(creators_file_path, overnight_file_path, day_file_path, prime_file_path):
|
| 111 |
try:
|
| 112 |
+
# Log file paths for debugging
|
| 113 |
+
print(f"DEBUG: Creators File Path: {creators_file_path}")
|
| 114 |
+
print(f"DEBUG: Overnight File Path: {overnight_file_path}")
|
| 115 |
+
print(f"DEBUG: Day File Path: {day_file_path}")
|
| 116 |
+
print(f"DEBUG: Prime File Path: {prime_file_path}")
|
| 117 |
+
|
| 118 |
+
# Read files
|
| 119 |
+
creators_data = pd.read_excel(creators_file_path)
|
| 120 |
+
overnight_data = pd.read_excel(overnight_file_path)
|
| 121 |
+
day_data = pd.read_excel(day_file_path)
|
| 122 |
+
prime_data = pd.read_excel(prime_file_path)
|
|
|
|
| 123 |
|
| 124 |
+
print("DEBUG: Creators File Columns:", creators_data.columns)
|
|
|
|
|
|
|
| 125 |
|
| 126 |
+
# Validate structure
|
| 127 |
+
if not {"Creator", "ActiveFans"}.issubset(creators_data.columns):
|
| 128 |
+
raise KeyError("The account data must contain 'Creator' and 'ActiveFans' columns.")
|
|
|
|
| 129 |
|
| 130 |
+
# Pass data to generate_schedule
|
| 131 |
+
chatter_files = [overnight_data, day_data, prime_data]
|
| 132 |
full_schedule = generate_schedule(chatter_files, creators_data)
|
| 133 |
+
|
| 134 |
return full_schedule
|
| 135 |
except Exception as e:
|
| 136 |
return f"Error generating schedule: {e}"
|