godspeed app sync
This commit is contained in:
110
demo_cancelled_workflow.py
Normal file
110
demo_cancelled_workflow.py
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Demo showing cancelled task workflow with Godspeed sync.
|
||||
"""
|
||||
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def demo_cancelled_workflow():
|
||||
print("=== Godspeed Cancelled Task Workflow Demo ===\n")
|
||||
|
||||
from src.services.godspeed.sync import GodspeedSync
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
sync_dir = Path(temp_dir)
|
||||
sync_engine = GodspeedSync(None, sync_dir)
|
||||
|
||||
print("📝 Scenario: Managing a project with tasks that get cancelled")
|
||||
print("=" * 65)
|
||||
|
||||
# Initial tasks
|
||||
print("\n1. Initial project tasks in markdown:")
|
||||
initial_tasks = [
|
||||
("task1", "incomplete", "Design new feature", ""),
|
||||
("task2", "incomplete", "Get approval from stakeholders", ""),
|
||||
("task3", "incomplete", "Implement feature", ""),
|
||||
("task4", "incomplete", "Write documentation", ""),
|
||||
("task5", "incomplete", "Deploy to production", ""),
|
||||
]
|
||||
|
||||
project_file = sync_dir / "New_Feature_Project.md"
|
||||
sync_engine._write_list_file(project_file, initial_tasks)
|
||||
|
||||
with open(project_file, "r") as f:
|
||||
print(f.read())
|
||||
|
||||
print("2. Project update - some tasks completed, one cancelled:")
|
||||
print("-" * 58)
|
||||
|
||||
# Simulate project evolution
|
||||
updated_content = """- [x] Design new feature <!-- id:task1 -->
|
||||
- [-] Get approval from stakeholders <!-- id:task2 -->
|
||||
Stakeholders decided to cancel this feature
|
||||
- [-] Implement feature <!-- id:task3 -->
|
||||
No longer needed since feature was cancelled
|
||||
- [-] Write documentation <!-- id:task4 -->
|
||||
Documentation not needed for cancelled feature
|
||||
- [-] Deploy to production <!-- id:task5 -->
|
||||
Cannot deploy cancelled feature
|
||||
- [ ] Archive project files <!-- id:task6 -->
|
||||
New cleanup task
|
||||
"""
|
||||
|
||||
with open(project_file, "w") as f:
|
||||
f.write(updated_content)
|
||||
|
||||
print(updated_content)
|
||||
|
||||
# Parse the changes
|
||||
updated_tasks = sync_engine._read_list_file(project_file)
|
||||
|
||||
print("3. What would sync to Godspeed API:")
|
||||
print("-" * 36)
|
||||
|
||||
api_calls = []
|
||||
for local_id, status, title, notes in updated_tasks:
|
||||
if status == "complete":
|
||||
api_calls.append(
|
||||
f"PATCH /tasks/{local_id} {{'is_complete': True, 'is_cleared': False}}"
|
||||
)
|
||||
print(f" ✅ COMPLETE: {title}")
|
||||
elif status == "cleared":
|
||||
api_calls.append(
|
||||
f"PATCH /tasks/{local_id} {{'is_complete': True, 'is_cleared': True}}"
|
||||
)
|
||||
print(f" ❌ CANCEL: {title}")
|
||||
if notes:
|
||||
print(f" Reason: {notes}")
|
||||
elif local_id == "task6": # New task
|
||||
api_calls.append(
|
||||
f"POST /tasks {{'title': '{title}', 'list_id': 'project-list'}}"
|
||||
)
|
||||
print(f" ➕ NEW: {title}")
|
||||
else:
|
||||
print(f" ⏳ INCOMPLETE: {title}")
|
||||
|
||||
print(f"\n4. API calls that would be made ({len(api_calls)} total):")
|
||||
print("-" * 49)
|
||||
for call in api_calls:
|
||||
print(f" {call}")
|
||||
|
||||
print("\n5. Next sync download behavior:")
|
||||
print("-" * 32)
|
||||
print(" When downloading from Godspeed API:")
|
||||
print(" • Only incomplete tasks appear in local files")
|
||||
print(" • Completed and cancelled tasks are hidden")
|
||||
print(" • This keeps your local markdown files clean")
|
||||
print(f" • Current file would only show: 'Archive project files'")
|
||||
|
||||
print("\n✨ Benefits of this workflow:")
|
||||
print(" • Clear visual distinction: [-] for cancelled vs [x] for completed")
|
||||
print(" • Cancelled tasks sync to Godspeed's 'cleared' status")
|
||||
print(" • Completed/cancelled tasks auto-hide on next download")
|
||||
print(" • Notes explain why tasks were cancelled")
|
||||
print(" • Clean local files focused on active work")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo_cancelled_workflow()
|
||||
Reference in New Issue
Block a user