Skip to content

Commit 4ca7adc

Browse files
authored
Merge pull request #44 from Comfy-Org/sno-bugcop-update-existed-task
fix: update gh-bugcop to use actual issue labels and disable dry run
2 parents cd63ba6 + a7d5d54 commit 4ca7adc

File tree

10 files changed

+266
-285
lines changed

10 files changed

+266
-285
lines changed

app/(dashboard)/getTotalsData.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline";
33
import { Totals } from "@/src/Totals";
44
import { flatten } from "flat";
5-
import sf from "sflow";
5+
import { sflow } from "sflow";
66

77
export async function getTotalsData() {
8-
return sf(
8+
return sflow(
99
$pipeline(Totals)
1010
.match({ "totals.data": { $exists: true } })
1111
.match({ "totals.mtime": { $gt: new Date(+new Date() - 86400e3 * 30) } }) // 1 month

app/tasks/gh-bugcop/GithubBugcopTaskStatus.tsx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@ export default function GithubBugcopTaskStatus({}) {
1414
const [data, setData] = useState<WithId<GithubBugcopTask>[]>([]);
1515
const [logs, setLogs] = useState<string[]>([]);
1616

17+
// Color mappers
18+
const getStatusColor = (labels?: string[]) => {
19+
if (labels?.includes(ASKING_LABEL)) return "yellow";
20+
if (labels?.includes(ANSWERED_LABEL)) return "green";
21+
return "red";
22+
};
23+
24+
const taskStatusColorMap: Record<string, string> = {
25+
responseReceived: "green",
26+
askForInfo: "yellow",
27+
};
28+
29+
const taskActionColorMap: Record<string, string> = {
30+
ok: "green",
31+
processing: "yellow",
32+
error: "red",
33+
};
34+
35+
const getUpdatedAtColor = (updatedAt?: Date) => {
36+
if (!updatedAt) return "gray";
37+
const daysSince = (Date.now() - updatedAt.getTime()) / (1000 * 60 * 60 * 24);
38+
if (daysSince < 3) return "green";
39+
if (daysSince < 7) return "yellow";
40+
if (daysSince < 15) return "red";
41+
return "gray";
42+
};
43+
1744
useAsyncEffect(async () => {
1845
const ac = new AbortController();
1946
// init query
@@ -79,23 +106,9 @@ export default function GithubBugcopTaskStatus({}) {
79106

80107
<Text color="blue">Status:</Text>
81108
{data.map((task) => {
82-
const statusColor = task.labels?.includes(ASKING_LABEL)
83-
? "yellow"
84-
: task.labels?.includes(ANSWERED_LABEL)
85-
? "green"
86-
: "red";
87-
88-
// Status colors
89-
const taskStatusColor =
90-
task.status === "answered" ? "green" : task.status === "ask-for-info" ? "yellow" : "red";
91-
const taskActionColor =
92-
task.taskStatus === "ok"
93-
? "green"
94-
: task.taskStatus === "processing"
95-
? "yellow"
96-
: task.taskStatus === "error"
97-
? "red"
98-
: "gray";
109+
const statusColor = getStatusColor(task.labels);
110+
const taskStatusColor = taskStatusColorMap[task.status ?? ""] ?? "red";
111+
const taskActionColor = taskActionColorMap[task.taskStatus ?? ""] ?? "gray";
99112

100113
return (
101114
<Box key={task.url} flexDirection="column">
@@ -113,16 +126,7 @@ export default function GithubBugcopTaskStatus({}) {
113126
</Box>
114127
<Box flexDirection="row">
115128
<Text> ├─ Updated at: </Text>
116-
<Text
117-
color={(() => {
118-
if (!task.updatedAt) return "gray";
119-
const daysSince = (Date.now() - new Date(task.updatedAt).getTime()) / (1000 * 60 * 60 * 24);
120-
if (daysSince < 3) return "green";
121-
if (daysSince < 7) return "yellow";
122-
if (daysSince < 15) return "red";
123-
return "gray";
124-
})()}
125-
>
129+
<Text color={getUpdatedAtColor(task.updatedAt)}>
126130
{task.updatedAt
127131
? prettyMilliseconds(Date.now() - new Date(task.updatedAt).getTime()) + " ago"
128132
: "never"}

0 commit comments

Comments
 (0)