This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Factory } from 'miragejs'; | ||
|
||
export default Factory.extend({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Model, belongsTo } from 'miragejs'; | ||
|
||
export default Model.extend({ | ||
application: belongsTo(), | ||
workspace: belongsTo(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { QueueJobRequest, QueueJobResponse } from 'waypoint-pb'; | ||
import { Request, Response } from 'miragejs'; | ||
import { decode } from '../helpers/protobufs'; | ||
|
||
export function queue(schema: any, { requestBody }: Request): Response { | ||
let requestMsg = decode(QueueJobRequest, requestBody); | ||
let job = requestMsg.getJob(); | ||
let projectName = job.getApplication().getProject(); | ||
let applicationName = job.getApplication().getApplication(); | ||
let workspaceName = job.getWorkspace().getWorkspace(); | ||
let project = schema.projects.findBy({ name: projectName }); | ||
let application = schema.applications.findBy({ name: applicationName, projectId: project.id }); | ||
let workspace = schema.workspaces.findBy({ name: workspaceName }); | ||
let result = new QueueJobResponse(); | ||
// TODO: pull more details from the request | ||
let model = schema.jobs.create({ application, workspace }); | ||
|
||
result.setJobId(model.id); | ||
|
||
return this.serialize(result, 'application'); | ||
} |