From 5a85f2bf811d2319164c2a5540775840bf5b9217 Mon Sep 17 00:00:00 2001 From: borean Date: Thu, 7 Mar 2024 21:57:27 +0100 Subject: [PATCH] first draft of AddTimeReport in db.go --- backend/internal/database/db.go | 11 +++++++---- backend/internal/model/timereport | 19 ------------------- 2 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 backend/internal/model/timereport diff --git a/backend/internal/database/db.go b/backend/internal/database/db.go index 84937f1..b000ae4 100644 --- a/backend/internal/database/db.go +++ b/backend/internal/database/db.go @@ -5,6 +5,7 @@ import ( "log" "os" "path/filepath" + "time" "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" @@ -36,7 +37,8 @@ const userInsert = "INSERT INTO users (username, password) VALUES (?, ?)" const projectInsert = "INSERT INTO projects (name, description, user_id) SELECT ?, ?, id FROM users WHERE username = ?" const promoteToAdmin = "INSERT INTO site_admin (admin_id) SELECT id FROM users WHERE username = ?" -// const addTimeReport = "" +const addTimeReport = "INSERT INTO activity (report_id, activity_nbr, start_time, end_time, break, comment) VALUES (?, ?, ?, ?, ?, ?)" + // const addUserToProject = "" // const changeUserRole = "" @@ -57,9 +59,10 @@ func DbConnect(dbpath string) Database { return &Db{db} } -// func (d *Db) AddTimeReport(projectname string, start time.Time, end time.Time) error { - -// } +func (d *Db) AddTimeReport(projectname string, start time.Time, end time.Time, breakTime uint32) error { // WIP + _, err := d.Exec(addTimeReport, projectname, 0, start, end, breakTime, false) + return err +} // func (d *Db) AddUserToProject(username string, projectname string) error { diff --git a/backend/internal/model/timereport b/backend/internal/model/timereport deleted file mode 100644 index d48c5fb..0000000 --- a/backend/internal/model/timereport +++ /dev/null @@ -1,19 +0,0 @@ -package model - -type TimeReport struct { - reportId string - projectName string - userName string - userRole string - reportDate string - timeWorked uint64 - isSigned bool - reportStatus string // Example "draft", "signed", "unsigned" -} - -type Project struct { - timeReports []TimeReport - projectName string - projectmembers map[string]User - projectRoles map[string]User -}