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 -}