also looking at this
Sync Bluesky engagement metrics into analytics
#12
10 files
+200
-4
| @@ -0,0 +1,24 @@ | ||
| 1 | import { Job } from '@stacksjs/queue' | |
| 2 | import { Every } from '@stacksjs/types' | |
| 3 | import { bluesky } from '../Services/Social/BlueskyService' | |
| 4 | ||
| 5 | export default new Job({ | |
| 6 | name: 'SyncEngagementMetrics', | |
| 7 | description: 'Refresh Bluesky engagement counts into post_targets.metrics', | |
| 8 | queue: 'default', | |
| 9 | tries: 1, | |
| 10 | backoff: 3, | |
| 11 | rate: Every.HalfHour, | |
| 12 | ||
| 13 | handle: async () => { | |
| 14 | try { | |
| 15 | const { synced } = await bluesky.syncMetrics() | |
| 16 | if (synced) console.log(`[postline] engagement sync: ${synced} targets refreshed`) | |
| 17 | return { synced } | |
| 18 | } | |
| 19 | catch (error) { | |
| 20 | // No connected account yet is normal on fresh installs — stay quiet. | |
| 21 | return { synced: 0, skipped: error instanceof Error ? error.message : String(error) } | |
| 22 | } | |
| 23 | }, | |
| 24 | }) | |