timekeeper

[Abandoned unfinished] CGI web application in C for time tracking. (My first, just a learning project)
Log | Files | Refs | README

commit 197643005dc96cc97bf085a8a26893d26c0cdb35
parent e9d268bed2ab369cfc0974f8a0b07bb18d8b466b
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Sun, 31 Mar 2024 18:11:52 -0700

Add trigger to set break end on time end

Now if a break was started and the end time set before the break
was ended, the end of the break is set to the end time.  Before
this was done to the data read from the database, but I like this
method better.

Diffstat:
Mpages/main.c | 12------------
Mstmt.c | 7+++++++
Mstmt.h | 1+
3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/pages/main.c b/pages/main.c @@ -134,18 +134,6 @@ printtime(struct pagedata *pd, struct timesheet *ts) (status = khtml_closeelem(&pd->html, 1)) != KCGI_OK) return status; - /* - * This should probably be done to the data itself so that - * future operations such as exporting have valid data. Or - * just make the data specification say that an end time - * with no break end time but a start break time mean the - * break end time is the end time. - */ - if (ts->set & BreakStartTimeFlag && - !(ts->set & BreakEndTimeFlag) && - ts->set & EndTimeFlag) - timesheet_set(ts, BreakEndTime, ts->times[EndTime]); - for (i = 0; i < 4; ++i) { if ((status = khtml_elem(&pd->html, KELEM_TD)) != KCGI_OK) return status; diff --git a/stmt.c b/stmt.c @@ -52,6 +52,13 @@ struct sqlbox_pstmt pstmts[] = { " );\n" "END" }, + [StmtInit6] = { .stmt = + "CREATE TRIGGER IF NOT EXISTS end_break_on_end\n" + " AFTER UPDATE OF end ON times FOR EACH ROW BEGIN\n" + " UPDATE times SET endbreak = new.end\n" + " WHERE entry IS old.entry AND endbreak ISNULL;\n" + "END" + }, [StmtInitLast] = { .stmt = "CREATE TRIGGER IF NOT EXISTS userdelete\n" " AFTER DELETE ON auth FOR EACH ROW BEGIN\n" diff --git a/stmt.h b/stmt.h @@ -5,6 +5,7 @@ enum StmtID { StmtInit3, StmtInit4, StmtInit5, + StmtInit6, StmtInitLast, StmtAddUser, StmtGetUserByHash,