Skip to content

Commit

Permalink
fix(back): AREAs QA
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenComp committed Nov 5, 2023
1 parent 95f363a commit 92be750
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
2 changes: 2 additions & 0 deletions backend/back/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import { CreateTodoistTaskReactions1699140054686 } from "./workflows/seed/169914
import { CreateAreaService1699143731594 } from "./services/seed/1699143731594-CreateAreaService";
import { CreateAreaOnActionAction1699145276143 } from "./workflows/seed/1699145276143-CreateAreaOnActionAction";
import { CreateAreaAreas1699152935342 } from "./workflows/seed/1699152935342-CreateAreaAreas";
import { FixAddScopeToLinearOnIssueCreate1699190007820 } from "./workflows/seed/1699190007820-FixAddScopeToLinearOnIssueCreate";

dotenv.config();

Expand Down Expand Up @@ -175,6 +176,7 @@ export const DATA_SOURCE_OPTIONS: DataSourceOptions = {
CreateAreaService1699143731594,
CreateAreaOnActionAction1699145276143,
CreateAreaAreas1699152935342,
FixAddScopeToLinearOnIssueCreate1699190007820,
],
synchronize: process.env.NODE_ENV === "development",
};
Expand Down
2 changes: 1 addition & 1 deletion backend/back/src/grpc/grpc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class GrpcService implements OnModuleInit {
await this.jobsService.launchNextJob(data);

if (data.name === "area-on-action") return;
const owners = await this.jobsService.getWorkflowOwnersForJob(data.identifier);
const owners = await this.jobsService.getWorkflowOwnersForAction(data.identifier);
for (const owner of owners) {
await this.onAction({
name: "area-on-action",
Expand Down
4 changes: 2 additions & 2 deletions backend/back/src/jobs/jobs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export class JobsService {
return reactionJobs;
}

async getWorkflowOwnersForJob(jobId: string): Promise<string[]> {
async getWorkflowOwnersForAction(jobId: string, active?: boolean): Promise<string[]> {
const jobs = await this.workflowAreaRepository.find({
where: { jobId },
where: { jobId, actionOfWorkflow: { active } },
relations: { actionOfWorkflow: true },
});
const owners = jobs.map((job) => job.actionOfWorkflow.ownerId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class FixAddScopeToLinearOnIssueCreate1699190007820 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`INSERT INTO "area_service_scopes_needed_service_scope"
("area_id", "area_service_id", "service_scope_id", "service_scope_service_id")
VALUES ('on-issue-create', 'linear', 'read', 'linear')`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM "area_service_scopes_needed_service_scope"
WHERE "area_id" = 'on-issue-create' AND "area_service_id" = 'linear' AND "service_scope_id" = 'read' AND "service_scope_service_id" = 'linear'`,
);
}
}
1 change: 1 addition & 0 deletions backend/supervisor/jobs/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var JobToImage = map[string]string{
"github-on-issue-reopen": "supervisor-github",
"github-on-pull-request-close": "supervisor-github",
"github-on-pull-request-create": "supervisor-github",
"github-on-pull-request-merge": "supervisor-github",
"gitlab-on-commit": "supervisor-gitlab",
"gitlab-on-pull-request-close": "supervisor-gitlab",
"gitlab-on-pull-request-create": "supervisor-gitlab",
Expand Down
4 changes: 2 additions & 2 deletions backend/workers/linear/src/issues/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { onError, onReaction } from "../util/grpc";
import parseArguments, { LinearAuthSchema } from "../util/params";
import { LinearErrorData } from "../util/types";

const PriorityArray = ["Low", "Medium", "High", "Urgent"];
const PriorityArray = ["Urgent", "High", "Medium", "Low"];

const CreateIssueSchema = z.object({
auth: LinearAuthSchema,
Expand All @@ -16,7 +16,7 @@ const CreateIssueSchema = z.object({
workflowStepId: z.string(),
title: z.string(),
description: z.string().optional(),
estimate: z.preprocess((a) => parseInt(z.string().parse(a), 10), z.number().positive()).optional(),
estimate: z.preprocess((a) => parseInt(z.string().parse(a), 10), z.number().nonnegative()).optional(),
priority: z
.preprocess((a) => {
const priority = z.string().parse(a);
Expand Down
2 changes: 1 addition & 1 deletion backend/workers/todoist/src/tasks/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function deleteTask() {
try {
const todoist = new TodoistApi(params.auth.access_token);

await todoist.closeTask(params.id);
await todoist.deleteTask(params.id);
await onReaction(client, {
name: "todoist-delete-task",
identifier: params.identifier,
Expand Down

0 comments on commit 92be750

Please sign in to comment.