mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 16:23:23 +00:00
Extract job scheduling logic into dedicated utility functions
♻️ Refactoring: - Created new jobScheduler.ts utility module - Extracted findExistingJobs() for duplicate detection - Extracted ensureEmailJob() for job creation with duplicate prevention - Extracted updateEmailJobRelationship() for relationship management 📦 Functions: - findExistingJobs(): Queries for existing processing jobs by email ID - ensureEmailJob(): Creates job only if none exists, returns job IDs - updateEmailJobRelationship(): Updates email with job relationship 🎯 Benefits: - Reusable functions for job management - Single source of truth for job scheduling logic - Cleaner, more testable code - Exported utilities for external use - Better separation of concerns 🔧 Updated: - Emails collection hooks now use extracted functions - Exports added to main index for public API - Cleaner hook implementation with less duplication
This commit is contained in:
@@ -29,4 +29,7 @@ export {
|
||||
} from './utils/helpers.js'
|
||||
|
||||
// Email processing utilities
|
||||
export { processEmailById, processAllEmails } from './utils/emailProcessor.js'
|
||||
export { processEmailById, processAllEmails } from './utils/emailProcessor.js'
|
||||
|
||||
// Job scheduling utilities
|
||||
export { findExistingJobs, ensureEmailJob, updateEmailJobRelationship } from './utils/jobScheduler.js'
|
||||
Reference in New Issue
Block a user