10 Commits

Author SHA1 Message Date
d5d2fa5836 Bugfix "Not sending 'Todays Events'"
Format Month and Day with a Leading 0 for values between 1 to 9 when querying the DB for Todays Events only.
2025-11-07 00:27:45 +00:00
ca102190ea Changed: only get Events from the Db which are not marked as deleted, indicated by having a value for "deleteDate" 2025-11-07 00:25:15 +00:00
8fee748837 Added "hour" to getTsNow() 2025-11-07 00:24:03 +00:00
c6ec442c2b Merge branch 'main' into dev 2025-11-06 20:16:54 +00:00
3e5032caf3 Merge branch 'dev' 2025-11-06 20:09:55 +00:00
2f805c0772 Bugfix: Added "deleted" as Notification State if Event deleteDate is set to 2025-11-06 20:08:08 +00:00
8aef42396e Merge branch 'version/0.1.5' 2025-11-06 17:48:10 +00:00
a37d95709f Merge pull request 'version/0.1.4' (#9) from version/0.1.4 into main
Reviewed-on: #9
2025-11-03 00:41:45 +00:00
152c1bcba0 Version Bump 0.1.4 2025-11-03 00:35:40 +00:00
ae569b7739 Merge pull request 'Bugfix in sendNotification()' (#6) from version/0.1.3 into main
Reviewed-on: #6
2025-10-27 16:55:12 +00:00
3 changed files with 11 additions and 9 deletions

View File

@@ -21,8 +21,8 @@ async function events_update_db() {
const events_fetched_list_of_uids = events_fetched.map( event => { return event.uid; });
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_nextMonth = Event.get_events({month: {year: TODAY.year, month: (TODAY.month + 1)}}, 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)}, deleted: false}, db);
const events_db = [... events_db_currentMonth, ... events_db_nextMonth];
const events_removed: Event[] = events_db.filter( (ev) => {
return ! events_fetched_list_of_uids.includes(ev.uid);
@@ -102,9 +102,10 @@ async function events_check_for_notification() {
await sendNotification( ev.get_title(), ev.get_body(), notificationOptions );
if ( ev.notification == "removed" ) {
ev.set_deleted( db );
}
} else {
ev.set_notification("done", db);
}
}
}
async function main ( ) {

View File

@@ -19,7 +19,7 @@ export type TGetEventsOptions = {
}
export type TEventEntity = TEvent & {
event_uid: number
notification: "new" | "changed" | "removed" | "done"
notification: "new" | "changed" | "removed" | "done" | "deleted"
}
export type TEventEntityNew = Omit<TEventEntity, "event_uid">
@@ -95,10 +95,10 @@ export class Event implements TEventEntity {
whereConditions.push( `notification IN ('${ options.notification.join("', '") }')` )
}
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 ) {
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 = ( () => {
@@ -176,8 +176,7 @@ export class Event implements TEventEntity {
set_notification ( newValue: TEventEntity["notification"], db: Database ) {
const query = db.prepare(
`UPDATE events
SET notification = $notification,
deleteDate = NULL
SET notification = $notification
WHERE event_uid = $event_uid;`
);
query.get({$notification: newValue, $event_uid: this.event_uid });
@@ -186,7 +185,8 @@ export class Event implements TEventEntity {
set_deleted ( db: Database ) {
const query = db.prepare(
`UPDATE events
SET deleteDate = $deleteDate
SET notification = 'deleted',
deleteDate = $deleteDate
WHERE event_uid = $event_uid;`
);
query.get({

View File

@@ -34,6 +34,7 @@ export function getTsNow() {
year: now.getFullYear(),
month: now.getMonth() + 1,
day: now.getDate(),
hour: now.getHours(),
minute: now.getMinutes(),
seconds: now.getSeconds()
}