Sync Ops

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[2.0.9] - 2025-12-22

Added

  • Documentation System: Added server-side Markdown rendering for documentation pages
  • New /docs route with dynamic documentation listing organized by folders
  • Markdown files rendered with syntax highlighting, tables, and code blocks
  • Support for nested folder structure in documentation
  • Swagger UI Integration: Added interactive API documentation
  • Flasgger integration for Swagger UI at /api-docs
  • Swagger YAML docstrings added to key endpoints (/applications/funding, /clickup-webhook/funding, /lokallag/global-sync)
  • Link to Swagger UI added on documentation index page
  • Staff Documentation Section: Added "For ansatte" section with non-technical guides
  • "Hvordan Bruke Lokallag" - Practical guide for working with lokallag
  • "Hvordan Etablere en Søknad" - Step-by-step guide for establishing funding applications
  • Changelog in UI: Changelog now accessible in the application
  • New /docs/changelog route rendering CHANGELOG.md
  • Footer link to changelog on all pages

Changed

  • Navigation Updates:
  • Renamed "Dev Docs" to "Docs" in navigation menu
  • Removed "Help" menu item from navigation

Technical Details

  • Created app/api/docs.py blueprint for documentation routes
  • Added Markdown rendering with markdown library (extensions: fenced_code, tables, toc)
  • Added footer component to app/templates/base.html
  • Updated app/main.py to register docs blueprint and initialize Swagger
  • Added documentation styling to app/static/styles.css

[2.0.8] - 2025-12-20

Added

  • Cornerstone Status Sync to ClickUp: Funding status from Cornerstone is now synced back to ClickUp during sync operations
  • New ClickUp text field cornerstone_status (ID: 85f95089-1b61-4fe7-9cf3-55f58e7cf310) populated with Cornerstone status (e.g., "ACCEPTED")
  • Status synced after both create and update operations to Cornerstone
  • Works in sync engine, webhook handlers, and manual sync operations
  • Users can now create ClickUp views to filter fundings by status (e.g., not ACCEPTED)

Technical Details

  • Added cornerstone_status to CUSTOM_FIELDS in app/db/config.py
  • New helper functions in app/sync/funding.py:
  • get_fundings_from_cornerstone() - Fetches all fundings from Cornerstone GraphQL API
  • get_funding_status_from_cornerstone(funding_id) - Gets status of a specific funding (optimized to query single funding)
  • sync_cornerstone_status_to_clickup(task_id, funding_id) - Syncs status from Cornerstone to ClickUp
  • Updated FundingHandler._sync_to_cornerstone_update() and _sync_to_cornerstone_create() in app/sync/engine.py
  • Updated _create_cornerstone_funding() and _update_cornerstone_funding() in app/api/webhooks.py

[2.0.7] - 2025-12-20

Fixed

  • dato_soknad Bidirectional Sync: Fixed missing sync of dato_soknad field from ClickUp to WordPress
  • WordPress Meta Field Population: dato_soknad (søknadsdato) now properly syncs from ClickUp custom field (ID: d2420315-b6bf-497a-a4b3-2dcb099c191d) to WordPress meta field dato_soknad
  • Date Field Type Handling: Fixed dato_soknad being converted to string instead of integer timestamp in WordPress sync functions

Technical Details

  • Added dato_soknad to WordPress meta_fields in all four sync locations:
  • create_wordpress_funding_post() in app/sync/funding.py
  • _sync_to_wordpress() in app/sync/engine.py
  • sync_funding_to_external_systems() in app/sync/funding.py
  • _create_or_update_wordpress_post() in app/api/webhooks.py (webhook handler)
  • Added dato_soknad to date fields tuple in WordPress sync functions to ensure proper integer timestamp handling:
  • sync_wordpress_soknader_post_create()
  • sync_wordpress_soknader_post()
  • update_wordpress_soknader_post()
  • Converts date string (YYYY-MM-DD) to Unix timestamp (seconds) for WordPress JetEngine Date fields
  • Added debug logging for date field extraction from ClickUp
  • Added tools/test_dato_soknad.py utility script for debugging date field extraction

[2.0.6] - 2025-01-XX

Added

  • Auto-Create WordPress Posts for Fundings: Funding entities without WordPress posts now automatically get posts created during sync operations
  • Automatic Post Creation in Global Sync: Global sync now creates missing WordPress posts for fundings that exist in entity_map but lack wp_post_id
  • Manual Sync Post Creation: Manual sync operations (UI resync, inspector API, manual sync tool) now automatically create WordPress posts when missing

Enhanced

  • Unified WordPress Post Creation: All sync paths (global sync, manual sync, webhooks) now use the same logic for creating WordPress posts, ensuring consistency
  • Automatic Entity Map Updates: WordPress post IDs are automatically added to entity_map after post creation

Technical Details

  • Modified FundingHandler._sync_to_wordpress() to create posts when wp_post_id is missing
  • Reuses existing payload building logic for consistency with webhook handler
  • Duplicate prevention via sync_wordpress_soknader_post() which checks for existing posts by clickup_task_id
  • Works seamlessly with both global sync and manual sync operations

[2.0.5] - 2025-12-20

Fixed

  • Funding Sync Lokallag Lookup: Fixed sync errors when lokallag doesn't have Cornerstone ID in ClickUp custom fields
  • Entity Map as Source of Truth: All lokallag lookups now use entity_map database instead of ClickUp custom fields
  • Cornerstone Sync Reliability: Funding sync to Cornerstone now works correctly for all funding types (including Oppstart) when lokallag data exists in entity_map

Enhanced

  • Optimized ClickUp API Calls: Reduced unnecessary API calls by extracting lokallag ClickUp ID directly instead of fetching full task objects
  • Improved Error Messages: Better error logging when lokallag is not found in entity_map vs missing in ClickUp

Technical Details

  • Added get_linked_lokallag_clickup_id() helper function to extract lokallag ClickUp ID from relationship field
  • Updated _sync_to_cornerstone_update(), _sync_to_cornerstone_create(), and _sync_to_wordpress() to use entity_map lookup
  • Optimized extract_funding_data_for_cornerstone() to eliminate one unnecessary ClickUp API call

[2.0.4] - 2025-09-27

Enhanced

  • Taxonomy-Based Funding Types: Transitioned from meta fields to 'soknadstype' taxonomy for improved content organization
  • Dynamic Taxonomy Updates: WordPress posts now properly update taxonomy terms when ClickUp funding types change
  • Enhanced Filtering: Better content categorization using WordPress taxonomy system with terms: direkte, musiker, oppstart, prosjekt, tale

Fixed

  • Taxonomy Update Logic: Fixed issue where existing WordPress posts retained old taxonomy terms when funding types changed in ClickUp
  • Term Assignment: Proper taxonomy term replacement during post updates

[2.0.3] - 2025-09-17

Added

  • WordPress 'soknader' CPT Integration: Enhanced ClickUp funding webhook now creates WordPress posts in 'soknader' Custom Post Type
  • JetEngine Meta Fields Support: Full integration with JetEngine meta fields (prosjektbeskrivelse, soknadssum, innvilget_sum, dato, lokallag_wordpress_post_id)
  • Taxonomy-Based Funding Types: Transitioned from meta fields to 'soknadstype' taxonomy for better content organization
  • WordPress App Password Authentication: Secure authentication using WordPress application passwords
  • Søknadssum Field Integration: Added support for ClickUp 'Søknadssum' custom field (ID: 231fc8a5-8f8d-4408-a66d-d933b21e9b26)
  • Lokallag Relationship Mapping: Automatic linking of funding to lokallag via lokallag_wordpress_post_id

Enhanced

  • Funding Webhook Logic: WordPress posts created for ALL funding types, Cornerstone funding only for eligible types (Prosjekt, Oppstart, Direkte)
  • Entity Mapping Updates: WordPress post IDs now properly tracked in entity_map database
  • Date Format Handling: Correct Unix timestamp format for JetEngine Date fields
  • Duplicate Prevention: Update existing WordPress posts instead of creating duplicates
  • Funding Type Extraction: Enhanced ClickUp custom field extraction with detailed logging
  • Error Handling: Comprehensive error handling and logging for WordPress operations

Fixed

  • Date Display Issue: Fixed dates showing as "1970" by converting to proper Unix timestamps
  • WordPress Post Duplication: Resolved issue where multiple webhook calls created duplicate posts
  • Meta Field Population: All JetEngine meta fields now populate correctly when enabled for REST API
  • Authentication Issues: Resolved WordPress authentication problems with app password implementation

Technical Details

  • WordPress Endpoint: Uses /wp-json/wp/v2/soknader for 'soknader' CPT operations
  • Taxonomy Support: 'soknadstype' taxonomy with terms: direkte, musiker, oppstart, prosjekt, tale
  • Data Types: Proper handling of JetEngine field types (strings, integers, Unix timestamps)
  • Environment Variables: WP_APP_PASSWORD and WP_USERNAME for WordPress authentication

2.0.2 - 2025-09-10

Created entry in database entity_map when creating lokallag from dashboard

[2.0.1] - 2025-09-10

Added

  • Comprehensive Entity Inspector System: Debug and fix entity mapping inconsistencies with ease
  • Advanced Monitoring Dashboard: Real-time sync monitoring with health scores and alerts
  • Manual ID Management: Text fields for manually populating missing cornerstone_id, clickup_id, and wp_post_id
  • Display Name Field: Added display_name column to entity_map with automatic population from Cornerstone/ClickUp
  • Navigation Header: Beautiful navigation across all dashboard pages
  • Auto-Fix Functions: Automatically search for and populate missing entity IDs
  • Orphaned Entity Handling: No ClickUp task is ever lost - creates entity mappings for all tasks
  • File Logging: Persistent logging to logs/sync_monitor.log for audit trails
  • CLI Tools: Command-line entity inspection and debugging tools
  • WordPress ID Capture: Automatic capture of WordPress post IDs during lokallag creation

Enhanced

  • Entity Mapping Logic: Robust entity resolution using entity_map, entity_stamps, and idempotency_keys
  • Sync Process: Now processes ALL ClickUp tasks (no data loss) with comprehensive monitoring
  • User Interface: Modern, responsive design with dashboard cards and intuitive navigation
  • Error Handling: Better validation and feedback for manual ID updates
  • Performance: Faster entity identification using stored display_name field

New Endpoints

  • GET /sync/dashboard - Real-time sync monitoring dashboard
  • GET /inspector/dashboard - Interactive entity debugging interface
  • POST /inspector/entities/{uuid}/set-cornerstone - Manually set Cornerstone ID
  • POST /inspector/entities/{uuid}/set-clickup - Manually set ClickUp ID
  • POST /inspector/entities/{uuid}/set-wordpress - Manually set WordPress ID
  • GET /inspector/report - Comprehensive entity health report
  • POST /inspector/entities/{uuid}/fix - Auto-fix missing IDs

Fixed

  • ClickUp Name Fallback: Orphaned entities now use ClickUp task names as display_name
  • Missing ID Alerts: Real-time alerts for entities missing any of the three required IDs
  • Sync Reliability: Idempotency checks prevent duplicate webhook processing
  • Data Consistency: Centralized entity mapping prevents fragile string matching

2.0.0 - 2025-09-10

Optimised the project structure. Laying the foundation for starting developing with the database

[1.1.3] - 2025-05-20

Changed

  • Front-end form now points to /applications/create-new endpoint to fix 404 error when creating lokallag.

[1.1.2] - 2025-04-14

Added

  • New funding eligibility verification function to validate funding types
  • Comprehensive logging control via LOG_LEVEL environment variable
  • Added ENVIRONMENT variable to distinguish between production and development modes

Changed

  • Improved funding validation to strictly enforce allowed funding types
  • Reduced excessive debug logging for production deployment
  • Enhanced API responses with more detailed error messages
  • Reorganized code for better maintainability

Fixed

  • Fixed bug where non-eligible funding types (like "Tale") were being processed
  • Fixed duplicate logging configuration
  • Added proper error handling in server startup

[1.1.1] - 2025-04-14

Added

  • New specialized endpoint /clickup-webhook/funding for handling funding updates
  • Improved error handling with detailed comments in ClickUp tasks
  • Added environment variable support for all API credentials

Changed

  • Reduced verbose logging for production deployment
  • Improved token handling by automatically removing "Bearer " prefix
  • Enhanced security by moving credentials to environment variables

Fixed

  • Fixed issue with test comments being added multiple times to tasks
  • Fixed duplicate webhook responses
  • Fixed token handling for ClickUp API authentication
  • Resolved issues with webhook endpoint response format

[1.1.0] - 2025-04-13

Added

  • New endpoint /applications/funding to create/update funding in Cornerstone based on ClickUp task data
  • New endpoint /clickup-webhook to listen for ClickUp status changes and automatically create/update funding
  • Added support for linking ClickUp tasks to Cornerstone funding records
  • Automatic detection of funding type based on ClickUp task fields
  • Bidirectional syncing of funding IDs between systems

Changed

  • Renamed endpoint /lokallag/create-new to /applications/create-new for consistency
  • Improved error handling and logging across all endpoints

Fixed

  • Fixed authentication issues when communicating with Cornerstone GraphQL API
  • Fixed encoding issues with non-ASCII characters in descriptions

[1.0.0] - 2023-11-15

Added

  • Initial release with basic integration between ClickUp and Cornerstone
  • Global sync functionality to keep tasks updated
  • Ability to create new lokallag entries in both systems
  • Relationship management between tasks