Compare commits
12 Commits
version/0.
...
version/0.
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e47a3bc8a | |||
| eb0c5e1580 | |||
| d5d2fa5836 | |||
| ca102190ea | |||
| 8fee748837 | |||
| c6ec442c2b | |||
| 3e5032caf3 | |||
| 2f805c0772 | |||
| 8aef42396e | |||
| a37d95709f | |||
| 152c1bcba0 | |||
| ae569b7739 |
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: chiko/77th_eventcalendarntfy:v0.1.5
|
image: chiko/77th_eventcalendarntfy:v0.1.6
|
||||||
build: .
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/db:/opt/app/data/db
|
- ./data/db:/opt/app/data/db
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ for var in "${env_vars[@]}"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
export PATH="/root/.bun/bin:$PATH"
|
export PATH="/root/.bun/bin:$PATH"
|
||||||
bun run /opt/app/src/app.ts --today
|
bun run /opt/app/src/app.ts
|
||||||
|
|
||||||
# Start cron in foreground
|
# Start cron in foreground
|
||||||
exec cron -f
|
exec cron -f
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"name": "77th_eventcalendarnotification",
|
"name": "77th_eventcalendarnotification",
|
||||||
"module": "./src/app.ts",
|
"module": "./src/app.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ async function events_update_db() {
|
|||||||
const events_fetched_list_of_uids = events_fetched.map( event => { return event.uid; });
|
const events_fetched_list_of_uids = events_fetched.map( event => { return event.uid; });
|
||||||
console.dir( {events_fetched_list_of_uids} );
|
console.dir( {events_fetched_list_of_uids} );
|
||||||
|
|
||||||
const events_db_currentMonth = Event.get_events({month: {year: TODAY.year, month: TODAY.month}}, db);
|
const events_db_currentMonth = Event.get_events({month: {year: TODAY.year, month: TODAY.month}, deleted: false}, db);
|
||||||
const events_db_nextMonth = Event.get_events({month: {year: TODAY.year, month: (TODAY.month + 1)}}, db);
|
const events_db_nextMonth = Event.get_events({month: {year: TODAY.year, month: (TODAY.month + 1)}, deleted: false}, db);
|
||||||
const events_db = [... events_db_currentMonth, ... events_db_nextMonth];
|
const events_db = [... events_db_currentMonth, ... events_db_nextMonth];
|
||||||
const events_removed: Event[] = events_db.filter( (ev) => {
|
const events_removed: Event[] = events_db.filter( (ev) => {
|
||||||
return ! events_fetched_list_of_uids.includes(ev.uid);
|
return ! events_fetched_list_of_uids.includes(ev.uid);
|
||||||
@@ -102,10 +102,11 @@ async function events_check_for_notification() {
|
|||||||
await sendNotification( ev.get_title(), ev.get_body(), notificationOptions );
|
await sendNotification( ev.get_title(), ev.get_body(), notificationOptions );
|
||||||
if ( ev.notification == "removed" ) {
|
if ( ev.notification == "removed" ) {
|
||||||
ev.set_deleted( db );
|
ev.set_deleted( db );
|
||||||
}
|
} else {
|
||||||
ev.set_notification("done", db);
|
ev.set_notification("done", db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function main ( ) {
|
async function main ( ) {
|
||||||
console.log("Excecuting main()");
|
console.log("Excecuting main()");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export type TGetEventsOptions = {
|
|||||||
}
|
}
|
||||||
export type TEventEntity = TEvent & {
|
export type TEventEntity = TEvent & {
|
||||||
event_uid: number
|
event_uid: number
|
||||||
notification: "new" | "changed" | "removed" | "done"
|
notification: "new" | "changed" | "removed" | "done" | "deleted"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TEventEntityNew = Omit<TEventEntity, "event_uid">
|
export type TEventEntityNew = Omit<TEventEntity, "event_uid">
|
||||||
@@ -95,10 +95,10 @@ export class Event implements TEventEntity {
|
|||||||
whereConditions.push( `notification IN ('${ options.notification.join("', '") }')` )
|
whereConditions.push( `notification IN ('${ options.notification.join("', '") }')` )
|
||||||
}
|
}
|
||||||
if ( options.date ) {
|
if ( options.date ) {
|
||||||
whereConditions.push(`date_at = "${options.date.year}-${options.date.month}-${options.date.day}"`);
|
whereConditions.push(`date_at = "${options.date.year}-${pad_l2(options.date.month)}-${pad_l2(options.date.day)}"`);
|
||||||
}
|
}
|
||||||
if ( options.month ) {
|
if ( options.month ) {
|
||||||
whereConditions.push( `strftime('%Y-%m', date_at) = '${options.month.year}-${options.month.month}'`)
|
whereConditions.push( `strftime('%Y-%m', date_at) = '${options.month.year}-${pad_l2(options.month.month)}'`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const where = ( () => {
|
const where = ( () => {
|
||||||
@@ -176,8 +176,7 @@ export class Event implements TEventEntity {
|
|||||||
set_notification ( newValue: TEventEntity["notification"], db: Database ) {
|
set_notification ( newValue: TEventEntity["notification"], db: Database ) {
|
||||||
const query = db.prepare(
|
const query = db.prepare(
|
||||||
`UPDATE events
|
`UPDATE events
|
||||||
SET notification = $notification,
|
SET notification = $notification
|
||||||
deleteDate = NULL
|
|
||||||
WHERE event_uid = $event_uid;`
|
WHERE event_uid = $event_uid;`
|
||||||
);
|
);
|
||||||
query.get({$notification: newValue, $event_uid: this.event_uid });
|
query.get({$notification: newValue, $event_uid: this.event_uid });
|
||||||
@@ -186,7 +185,8 @@ export class Event implements TEventEntity {
|
|||||||
set_deleted ( db: Database ) {
|
set_deleted ( db: Database ) {
|
||||||
const query = db.prepare(
|
const query = db.prepare(
|
||||||
`UPDATE events
|
`UPDATE events
|
||||||
SET deleteDate = $deleteDate
|
SET notification = 'deleted',
|
||||||
|
deleteDate = $deleteDate
|
||||||
WHERE event_uid = $event_uid;`
|
WHERE event_uid = $event_uid;`
|
||||||
);
|
);
|
||||||
query.get({
|
query.get({
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export function getTsNow() {
|
|||||||
year: now.getFullYear(),
|
year: now.getFullYear(),
|
||||||
month: now.getMonth() + 1,
|
month: now.getMonth() + 1,
|
||||||
day: now.getDate(),
|
day: now.getDate(),
|
||||||
|
hour: now.getHours(),
|
||||||
minute: now.getMinutes(),
|
minute: now.getMinutes(),
|
||||||
seconds: now.getSeconds()
|
seconds: now.getSeconds()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user