fix: update task-loop section matching for Bug Intake project
- SECTIONS now uses arrays of candidate names searched in priority order - Maps Bug Intake sections: New Bugs→TODO, Under Review→IN_PROGRESS, Resolved→DONE - Added findFirstSection helper for array-based section lookup
This commit is contained in:
@@ -5,12 +5,11 @@ import { FileLock } from "./lock.js";
|
||||
import type { Config } from "../config.js";
|
||||
import type { AsanaTask } from "../asana/types.js";
|
||||
|
||||
// Section names in Asana board
|
||||
// Section names in Asana board (searched in order, partial case-insensitive match)
|
||||
const SECTIONS = {
|
||||
TODO: "To Do",
|
||||
IN_PROGRESS: "In Progress",
|
||||
DONE: "Done",
|
||||
PI_WORKER: "Pi Worker", // Optional dedicated section
|
||||
TODO: ["Pi Worker", "To Do", "New Bugs", "Ready for Development"],
|
||||
IN_PROGRESS: ["In Progress", "Under Review"],
|
||||
DONE: ["Done", "Resolved"],
|
||||
};
|
||||
|
||||
export class TaskLoop {
|
||||
@@ -92,11 +91,14 @@ export class TaskLoop {
|
||||
try {
|
||||
logger.info("task-loop", "Polling for Asana tasks...");
|
||||
|
||||
// Try dedicated "Pi Worker" section first, then "To Do"
|
||||
let tasks = await this.asana.getIncompleteTasks(this.config.asanaProjectGid, SECTIONS.PI_WORKER);
|
||||
|
||||
if (tasks.length === 0) {
|
||||
tasks = await this.asana.getIncompleteTasks(this.config.asanaProjectGid, SECTIONS.TODO);
|
||||
// Search TODO sections in priority order
|
||||
let tasks: AsanaTask[] = [];
|
||||
for (const sectionName of SECTIONS.TODO) {
|
||||
tasks = await this.asana.getIncompleteTasks(this.config.asanaProjectGid, sectionName);
|
||||
if (tasks.length > 0) {
|
||||
logger.info("task-loop", `Found ${tasks.length} task(s) in "${sectionName}"`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
@@ -117,10 +119,18 @@ export class TaskLoop {
|
||||
}
|
||||
}
|
||||
|
||||
private async findFirstSection(candidates: string[]) {
|
||||
for (const name of candidates) {
|
||||
const section = await this.asana.findSection(this.config.asanaProjectGid, name);
|
||||
if (section) return section;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private async executeTask(task: AsanaTask) {
|
||||
try {
|
||||
// Move to "In Progress"
|
||||
const inProgressSection = await this.asana.findSection(this.config.asanaProjectGid, SECTIONS.IN_PROGRESS);
|
||||
const inProgressSection = await this.findFirstSection(SECTIONS.IN_PROGRESS);
|
||||
if (inProgressSection) {
|
||||
await this.asana.moveTaskToSection(task.gid, inProgressSection.gid);
|
||||
}
|
||||
@@ -152,7 +162,7 @@ export class TaskLoop {
|
||||
|
||||
if (result.success) {
|
||||
// Move to "Done" and mark complete
|
||||
const doneSection = await this.asana.findSection(this.config.asanaProjectGid, SECTIONS.DONE);
|
||||
const doneSection = await this.findFirstSection(SECTIONS.DONE);
|
||||
if (doneSection) {
|
||||
await this.asana.moveTaskToSection(task.gid, doneSection.gid);
|
||||
}
|
||||
@@ -160,7 +170,7 @@ export class TaskLoop {
|
||||
logger.info("task-loop", `Task completed: ${task.name}`);
|
||||
} else {
|
||||
// Move back to To Do on failure
|
||||
const todoSection = await this.asana.findSection(this.config.asanaProjectGid, SECTIONS.TODO);
|
||||
const todoSection = await this.findFirstSection(SECTIONS.TODO);
|
||||
if (todoSection) {
|
||||
await this.asana.moveTaskToSection(task.gid, todoSection.gid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user