Skip to content

Commit 5a64651

Browse files
committed
Merge branch 'develop'
2 parents 3d0f87e + d366a35 commit 5a64651

File tree

18 files changed

+278
-183
lines changed

18 files changed

+278
-183
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Build with Tag
22

3+
on:
4+
push:
5+
36
on:
47
push:
58
tags:
6-
- '*' # Triggers on any tag
9+
- '*'
710

811
jobs:
912
build:
@@ -13,21 +16,25 @@ jobs:
1316
- name: Checkout code
1417
uses: actions/checkout@v3
1518

16-
- name: Set up PHP
17-
uses: shivammathur/setup-php@v2
19+
- uses: pnpm/action-setup@v4
20+
name: Install pnpm
1821
with:
19-
php-version: '8.2'
22+
version: 10
23+
run_install: false
2024

21-
- name: Install Composer dependencies
22-
run: composer install --no-interaction --prefer-dist --optimize-autoloader
23-
24-
- name: Set up Node.js
25-
uses: actions/setup-node@v3
26-
with:
27-
node-version: '20'
28-
29-
- name: Install Node dependencies
30-
run: npm ci
25+
# - name: Set up PHP
26+
# uses: shivammathur/setup-php@v2
27+
# with:
28+
# php-version: '8.2'
29+
#
30+
# - name: Install Composer dependencies
31+
# run: composer install --no-interaction --prefer-dist --optimize-autoloader
3132

3233
- name: Build assets
33-
run: npm run build
34+
run: cd themes/user/app; pnpm install; pnpm run build;
35+
36+
- name: Archive build artifacts
37+
run: |
38+
grep composer.json | xargs rm
39+
grep composer.lock | xargs rm
40+
zip -r ../release.zip .

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ To see working examples you can run the following commands.
185185
This will execute `queue/Commands/CommandQueueTest.php`, which adds 5 jobs to the queue, each an instance of `TestJob` (see below)
186186

187187
```bash
188-
php system/ee/eecli.php queue:test`
188+
php system/ee/eecli.php queue:test
189189
```
190190

191191
Then run this command, which will process the jobs, which calls the `fire()` method for each job.
192192

193193
```bash
194-
`php system/ee/eecli.php queue:work --limit=5`
194+
php system/ee/eecli.php queue:work --limit=5
195195
```
196196

197197
Example job class you can use as a starting point.

addons/queue/Queue/Drivers/DatabaseDriver.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ public function getPendingJobs(string $queueName = 'default'): array
9090
->get();
9191

9292
return array_map(function ($job) {
93-
return [
94-
'id' => $job->id,
95-
'queue' => $job->queue,
96-
'payload' => $job->payload,
97-
'attempts' => $job->attempts,
98-
'available_at' => $job->available_at,
99-
'created_at' => $job->created_at,
100-
'reserved_at' => $job->reserved_at,
101-
];
93+
return (new PendingJob(
94+
id: $job->id,
95+
queue: $job->queue,
96+
payload: $job->payload,
97+
attempts: $job->attempts ?? 0,
98+
available_at: $job->available_at ?? 0,
99+
created_at: $job->created_at ?? 0,
100+
reserved_at: $job->reserved_at ?? 0,
101+
))->toArray();
102102
}, $jobs->toArray());
103103
}
104104

@@ -113,14 +113,13 @@ public function getFailedJobs(string $queueName = 'default'): array
113113
->get();
114114

115115
return array_map(function ($job) {
116-
return [
117-
'id' => $job->id,
118-
'uuid' => $job->uuid,
119-
'queue' => $job->queue,
120-
'payload' => $job->payload,
121-
'exception' => $job->exception,
122-
'failed_at' => $job->failed_at,
123-
];
116+
return (new FailedJob(
117+
id: $job->id,
118+
uuid: $job->uuid,
119+
payload: $job->payload ?? '',
120+
failed_at: $job->failed_at ?? '',
121+
exception: $job->exception ?? '',
122+
))->toArray();
124123
}, $jobs->toArray());
125124
}
126125

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace BoldMinded\Queue\Queue\Drivers;
4+
5+
final class FailedJob
6+
{
7+
public function __construct(
8+
public int $id = 0,
9+
public string $uuid = '',
10+
public string $queue = 'default',
11+
public string $payload = '',
12+
public string $exception = '',
13+
public string $failed_at = '',
14+
) {}
15+
16+
public function toArray(): array
17+
{
18+
return [
19+
'id' => $this->id,
20+
'uuid' => $this->uuid,
21+
'queue' => $this->queue,
22+
'payload' => $this->payload,
23+
'exception' => $this->exception,
24+
'failed_at' => $this->failed_at,
25+
];
26+
}
27+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace BoldMinded\Queue\Queue\Drivers;
4+
5+
final class PendingJob
6+
{
7+
public function __construct(
8+
public string $id,
9+
public string $queue = 'default',
10+
public string $payload = '',
11+
public int $attempts = 0,
12+
public int $available_at = 0,
13+
public int $created_at = 0,
14+
public int $reserved_at = 0,
15+
) {}
16+
17+
public function toArray(): array
18+
{
19+
return [
20+
'id' => $this->id,
21+
'queue' => $this->queue,
22+
'payload' => $this->payload,
23+
'attempts' => $this->attempts,
24+
'available_at' => $this->available_at,
25+
'created_at' => $this->created_at,
26+
'reserved_at' => $this->reserved_at,
27+
];
28+
}
29+
}

addons/queue/Queue/Drivers/RedisDriver.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ private function getJobsFromQueue(string $queueName): array
132132
return array_map(function ($job) use ($queueName) {
133133
$decoded = json_decode($job);
134134

135-
return [
136-
'id' => $decoded->uuid,
137-
'queue' => $queueName,
138-
'payload' => $decoded->data,
139-
'attempts' => $decoded->attempts,
140-
'available_at' => $decoded->available_at ?? 0,
141-
'created_at' => $decoded->created_at ?? 0,
142-
'reserved_at' => $decoded->reserved_at ?? 0,
143-
];
135+
return (new PendingJob(
136+
id: $decoded->id,
137+
queue: $queueName,
138+
payload: (string) $decoded->data,
139+
attempts: $decoded->attempts ?? 0,
140+
available_at: $decoded->available_at ?? 0,
141+
created_at: $decoded->created_at ?? 0,
142+
reserved_at: $decoded->reserved_at ?? 0,
143+
))->toArray();
144144
}, $queueList);
145145
}
146146

themes/user/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"dependencies": {
1313
"react": "^19.0.0",
1414
"react-dom": "^19.0.0",
15-
"react-router": "^7.4.0"
15+
"react-router": "^7.4.0",
16+
"zod": "^3.24.2"
1617
},
1718
"devDependencies": {
1819
"@eslint/js": "^9.21.0",

themes/user/app/pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/user/app/src/BasicResponse.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import config from "./Config.ts";
2-
import { BasicResponse } from "./BasicResponse.ts";
2+
import { BasicResponse, BasicResponseSchema } from "./Queue.ts";
33

44
export default async function DeleteFailedJob(jobId: string): Promise<BasicResponse> {
55
const requestConfig = {
@@ -15,14 +15,12 @@ export default async function DeleteFailedJob(jobId: string): Promise<BasicRespo
1515
}),
1616
};
1717

18-
return await fetch(config.urlDeleteFailedJob, requestConfig)
19-
.then(res => res.json())
20-
.then(
21-
(result) => {
22-
return result;
23-
},
24-
(error) => {
25-
console.log(error);
26-
}
27-
);
18+
try {
19+
const response = await fetch(config.urlDeleteFailedJob, requestConfig);
20+
const data = await response.json();
21+
return BasicResponseSchema.parse(data);
22+
} catch (error) {
23+
console.error('Error deleting failed job:', error);
24+
throw error;
25+
}
2826
}

0 commit comments

Comments
 (0)