Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,7 +121,8 @@ def sync_to_notion(token, database_id, branch_data):
|
|
| 121 |
pages = response.json().get('results', [])
|
| 122 |
|
| 123 |
# Create a dictionary for the latest update time of each branch
|
| 124 |
-
|
|
|
|
| 125 |
|
| 126 |
# Status color mapping
|
| 127 |
status_colors = {
|
|
@@ -145,27 +146,20 @@ def sync_to_notion(token, database_id, branch_data):
|
|
| 145 |
existing_depends_on = [dep['name'] for dep in page['properties'].get('depends-on', {}).get('multi_select', [])]
|
| 146 |
break
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
break
|
| 163 |
-
if not latest_update:
|
| 164 |
-
status_tag = "empty"
|
| 165 |
-
elif outdated:
|
| 166 |
-
status_tag = "outdated"
|
| 167 |
-
else:
|
| 168 |
-
status_tag = "up-to-date"
|
| 169 |
|
| 170 |
# Prepare data for updating or creating a page
|
| 171 |
print (branch.get("url", ""))
|
|
|
|
| 121 |
pages = response.json().get('results', [])
|
| 122 |
|
| 123 |
# Create a dictionary for the latest update time of each branch
|
| 124 |
+
branch_details = {branch['Name']: {'updated': branch.get('updated', ''), 'commit_message': branch.get('commit_message', '')} for branch in branch_data}
|
| 125 |
+
|
| 126 |
|
| 127 |
# Status color mapping
|
| 128 |
status_colors = {
|
|
|
|
| 146 |
existing_depends_on = [dep['name'] for dep in page['properties'].get('depends-on', {}).get('multi_select', [])]
|
| 147 |
break
|
| 148 |
|
| 149 |
+
# Determine status based on dependencies
|
| 150 |
+
status_tag = "up-to-date" # Default status
|
| 151 |
+
for dependency_name in existing_depends_on:
|
| 152 |
+
dependency_info = branch_details.get(dependency_name, {})
|
| 153 |
+
branch_update_time = branch_details.get(branch['Name'], {}).get('updated', '')
|
| 154 |
+
|
| 155 |
+
# Check if the dependency is more recent and if its commit message does not contain 'isConnected'
|
| 156 |
+
if dependency_info.get('updated', '') > branch_update_time and "isConnected" not in dependency_info.get('commit_message', ''):
|
| 157 |
+
status_tag = "outdated"
|
| 158 |
+
break
|
| 159 |
+
|
| 160 |
+
# If there's no update information, set status to 'empty'
|
| 161 |
+
if not branch_update_time:
|
| 162 |
+
status_tag = "empty""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
# Prepare data for updating or creating a page
|
| 165 |
print (branch.get("url", ""))
|