Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

daily post to slack listing all the linear issues assigned to you that changed status. thrown together with https://aider.chat/ + sonnet

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const ISSUES_QUERY = `
query GetIssuesAssignedToCurrentUserByDate($startDate: DateTimeOrDuration!, $endDate: DateTimeOrDuration!) {
viewer {
assignedIssues(filter: {
or: [
{ canceledAt: { gte: $startDate, lt: $endDate } },
{ completedAt: { gte: $startDate, lt: $endDate } },
{ startedAt: { gte: $startDate, lt: $endDate } }
]
}) {
nodes {
id
identifier
title
updatedAt
state {
name
}
team {
id
name
}
}
}
}
}
`;
const ISSUE_HISTORY_QUERY = `
query GetIssueHistory($issueId: String!) {
issue(id: $issueId) {
history {
nodes {
createdAt
fromState {
name
}
toState {
name
}
}
}
}
}
`;
function getYesterdayDateRange(): { startDate: string; endDate: string } {
const now = new Date();
const yesterday = new Date(now.setDate(now.getDate() - 1));
yesterday.setHours(0, 0, 0, 0);
const startDate = yesterday.toISOString();
const endDate = new Date(
yesterday.setDate(yesterday.getDate() + 1),
).toISOString();
return { startDate, endDate };
}
export async function exec(interval: Interval) {
const apiKey = Deno.env.get("LINEAR_API_KEY");
if (!apiKey) {
console.error("LINEAR_API_KEY not found in environment variables");
Deno.exit(1);
}
const { startDate, endDate } = getYesterdayDateRange();
const response = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: apiKey,
},
body: JSON.stringify({
query: ISSUES_QUERY,
variables: { startDate, endDate },
}),
});
const data = await response.json();
if (data.errors) {
console.error("Error fetching data from Linear API:", data.errors);
Deno.exit(1);
}
const issues = data.data.viewer.assignedIssues.nodes;
// Group issues by team and fetch issue history
const issuesByTeam: { [teamName: string]: any[] } = {};
for (const issue of issues) {
const teamName = issue.team ? issue.team.name : "No Team";
if (!issuesByTeam[teamName]) {
issuesByTeam[teamName] = [];
}
const historyResponse = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: apiKey,
August 8, 2024