Skip to content

Commit b2175cd

Browse files
chore: wip
1 parent 5671651 commit b2175cd

File tree

9 files changed

+938
-13
lines changed

9 files changed

+938
-13
lines changed

storage/framework/core/queue/src/process.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ok, type Ok } from '@stacksjs/error-handling'
22
import { log } from '@stacksjs/logging'
3-
import { Job, type JobModel } from '../../../orm/src/models/Job'
3+
import { Job } from '../../../orm/src/models/Job'
44
import { runJob } from './job'
55

66
interface QueuePayload {
@@ -16,7 +16,8 @@ export async function processJobs(queue: string | undefined): Promise<Ok<string,
1616
async function process() {
1717
try {
1818
await executeJobs(queue)
19-
} catch (error) {
19+
}
20+
catch (error) {
2021
log.error('Error processing jobs:', error)
2122
}
2223

@@ -32,10 +33,11 @@ async function executeJobs(queue: string | undefined): Promise<void> {
3233
const jobs = await Job.when(queue !== undefined, (query: any) => query.where('queue', queue)).get()
3334

3435
for (const job of jobs) {
36+
if (!job.payload)
37+
continue
3538

36-
if (!job.payload) continue
37-
38-
if (job.available_at && job.available_at > timestampNow()) continue
39+
if (job.available_at && job.available_at > timestampNow())
40+
continue
3941

4042
const body: QueuePayload = JSON.parse(job.payload)
4143
const currentAttempts = job.attempts || 0
@@ -55,7 +57,8 @@ async function executeJobs(queue: string | undefined): Promise<void> {
5557

5658
await job.delete()
5759
log.info(`Successfully ran job: ${body.displayName}`)
58-
} catch (error) {
60+
}
61+
catch (error) {
5962
log.error(`Job failed: ${body.displayName}`, error)
6063
}
6164
}
@@ -64,7 +67,8 @@ async function executeJobs(queue: string | undefined): Promise<void> {
6467
async function updateJobAttempts(job: any, currentAttempts: number): Promise<void> {
6568
try {
6669
await job.update({ attempts: currentAttempts + 1 })
67-
} catch (error) {
70+
}
71+
catch (error) {
6872
log.error('Failed to update job attempts:', error)
6973
}
7074
}

storage/framework/core/queue/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function storeJob(name: string, options: QueueOption): Promise<void
1313
maxTries: options.tries || 1,
1414
timeout: null,
1515
timeoutAt: null,
16-
payload: options.payload || {}
16+
payload: options.payload || {},
1717
})
1818

1919
const job = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'Product' | 'PaymentMethod' | 'Transaction' | 'Job' | 'Subscription' | 'Error'
1+
export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'FailedJob' | 'Product' | 'PaymentMethod' | 'Transaction' | 'Job' | 'Subscription' | 'Error'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'personal_access_token_teams' | 'team_users' | 'teams' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'products' | 'payment_methods' | 'transactions' | 'jobs' | 'subscriptions' | 'errors'
1+
export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'personal_access_token_teams' | 'team_users' | 'teams' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'failed_jobs' | 'products' | 'payment_methods' | 'transactions' | 'jobs' | 'subscriptions' | 'errors'

storage/framework/database/models/generated/FailedJob.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
},
2626
factory: () => 'default',
2727
},
28-
28+
2929
queue: {
3030
required: true,
3131
fillable: true,
@@ -62,6 +62,6 @@ export default {
6262
rule: schema.date(),
6363
},
6464
factory: () => '2024-12-23 13:32:19',
65-
}
65+
},
6666
},
6767
} satisfies Model

0 commit comments

Comments
 (0)