Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iGEM.org Backend
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iGEM HQ Tech
iGEM.org Backend
Commits
d1ac054d
Commit
d1ac054d
authored
4 months ago
by
Tianyi Liang
Browse files
Options
Downloads
Patches
Plain Diff
[SD-235] job state
parent
e96155b2
No related branches found
Branches containing commit
No related tags found
1 merge request
!562
Resolve SD-235 "Feat/ booth screen video"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/videos/videos.controller.ts
+19
-1
19 additions, 1 deletion
src/modules/videos/videos.controller.ts
src/modules/videos/videos.job-queue.ts
+19
-1
19 additions, 1 deletion
src/modules/videos/videos.job-queue.ts
with
38 additions
and
2 deletions
src/modules/videos/videos.controller.ts
+
19
−
1
View file @
d1ac054d
import
{
Controller
,
Param
,
Post
}
from
'
@nestjs/common
'
import
{
Controller
,
Get
,
Param
,
Post
}
from
'
@nestjs/common
'
import
{
ApiTags
}
from
'
@nestjs/swagger
'
import
{
Job
}
from
'
bull
'
import
{
ActivityLogEvent
}
from
'
modules/activity-log/enums/activity-log-event.enum
'
...
...
@@ -42,4 +42,22 @@ export class VideosController {
event
:
ActivityLogEvent
.
TEAM_BOOTH_VIDEO_GENERATE
,
})
}
@
Get
(
'
jobs/:jobID
'
)
@
AssertStaffPrivilege
(
StaffPrivilegeKind
.
CAN_MANAGE_TEAMS
)
async
getJob
(@
Param
(
'
jobID
'
)
jobID
:
string
):
Promise
<
Job
|
null
>
{
return
await
this
.
jobQueue
.
fetchJob
(
jobID
)
}
@
Get
(
'
jobs/state/:jobID
'
)
@
AssertStaffPrivilege
(
StaffPrivilegeKind
.
CAN_MANAGE_TEAMS
)
async
getJobState
(@
Param
(
'
jobID
'
)
jobID
:
string
):
Promise
<
string
>
{
return
(
await
this
.
jobQueue
.
fetchJobState
(
jobID
))
as
string
}
@
Post
(
'
jobs/remove/:jobID
'
)
@
AssertStaffPrivilege
(
StaffPrivilegeKind
.
CAN_MANAGE_TEAMS
)
async
removeJob
(@
Param
(
'
jobID
'
)
jobID
:
string
):
Promise
<
void
>
{
await
this
.
jobQueue
.
removeJob
(
jobID
)
}
}
This diff is collapsed.
Click to expand it.
src/modules/videos/videos.job-queue.ts
+
19
−
1
View file @
d1ac054d
import
{
InjectQueue
,
Process
,
Processor
}
from
'
@nestjs/bull
'
import
{
Inject
,
forwardRef
}
from
'
@nestjs/common
'
import
{
Job
,
Queue
}
from
'
bull
'
import
{
Job
,
JobStatus
,
Queue
}
from
'
bull
'
import
{
JobQueue
}
from
'
lib/job-queue/job-queue.enum
'
import
{
VideosJobTypeEnum
}
from
'
modules/videos/enums/videos-job-type.enum
'
import
{
BatchProcessVideosJobPayload
}
from
'
modules/videos/job-payloads/batch-process-videos.job-payload
'
...
...
@@ -91,4 +91,22 @@ export class VideosJobQueue {
job
.
data
.
event
,
)
}
async
fetchJob
(
jobId
:
string
):
Promise
<
Job
|
null
>
{
return
await
this
.
queue
.
getJob
(
jobId
)
}
async
fetchJobState
(
jobId
:
string
):
Promise
<
JobStatus
|
'
stuck
'
|
undefined
>
{
const
job
=
await
this
.
queue
.
getJob
(
jobId
)
if
(
job
!=
null
)
{
return
await
job
.
getState
()
}
}
async
removeJob
(
jobId
:
string
):
Promise
<
void
>
{
const
job
=
await
this
.
queue
.
getJob
(
jobId
)
if
(
job
!=
null
)
{
await
job
.
remove
()
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment