Runs every 1 days
Fork
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
import { email } from "https://esm.town/v/std/email?v=9";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function EmailNotifIfDidntCode() {
type Data = DataItem[];
interface DataItem {
id: string;
type: string;
actor: any;
repo: any;
payload: any;
"public": boolean;
created_at: string;
org?: any;
}
const githubEvents = await fetchJSON(
"https://api.github.com/users/daviddkkim/events",
) as Data;
//early return if no github events
if (githubEvents.length < 1)
return;
const filteredEvents = githubEvents.filter((event) => {
return event.type === "PushEvent";
});
const latestPushEvent = filteredEvents[0];
const latestActivityDate = new Date(latestPushEvent.created_at);
const today = new Date();
if (latestActivityDate.getFullYear() != today.getFullYear()) {
await email({
text: "you gotta push some code my guy! Today is " + today.getFullYear() +
"-" + today.getMonth() + "-" + today.getDay(),
});
return;
}
if (latestActivityDate.getMonth() != today.getMonth()) {
await email({
text: "you gotta push some code my guy! Today is " + today.getFullYear() +
"-" + today.getMonth() + "-" + today.getDay(),
});
return;
}
if (latestActivityDate.getDay() != today.getDay()) {
await email({
text: "you gotta push some code my guy! Today is " + today.getFullYear() +
"-" + today.getMonth() + "-" + today.getDay(),
});
return;
}
await email({
text: "you coded today! " + today.getFullYear() + "-" + today.getMonth() +
"-" + today.getDay(),
});
return;
}