Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/workers/src/workers/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ export async function setupSchedules() {
{ pattern: '0 0 1 * * *' },
{ opts: { attempts: 1 } },
)

// Every day at 11 AM to add smth - This will be deleted after its run once
await maintenanceQueue.upsertJobScheduler(
'fillOnboardingsAsCompletedJob',
{ pattern: '0 0 11 * * *' },
{ opts: { attempts: 1 } },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const jobMappings = {
requestDocumentSuggestionsJob: jobs.requestDocumentSuggestionsJob,
scaleDownMcpServerJob: jobs.scaleDownMcpServerJob,
updateMcpServerLastUsedJob: jobs.updateMcpServerLastUsedJob,
fillOnboardingsAsCompletedJob: jobs.fillOnboardingsAsCompletedJob,
}

export function startMaintenanceWorker() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Job } from 'bullmq'
import { Result } from '../../../lib/Result'
import { workspaceOnboarding } from '../../../schema/models/workspaceOnboarding'
import { database } from '../../../client'
import { isNull } from 'drizzle-orm'

export type FillOnboardingsAsCompletedJobData = Record<string, never>

export const fillOnboardingsAsCompletedJob = async (
_: Job<FillOnboardingsAsCompletedJobData>,
) => {
const updatedOnboardings = await database
.update(workspaceOnboarding)
.set({
completedAt: new Date(),
})
.where(isNull(workspaceOnboarding.completedAt))
.returning()

return Result.ok({
success: true,
updatedOnboardings: updatedOnboardings.length,
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './refreshProjectsStatsCacheJob'
export * from './refreshProjectStatsCacheJob'
export * from './scheduleWorkspaceCleanupJobs'
export * from './cleanupWorkspaceOldLogsJob'
export * from './fillOnboardingsAsCompletedJob'
Loading