Compare commits
No commits in common. "78f5415d9abe407019c4615b94cab35634c3f303" and "fe91f798baefd0650c90ad7db0140d09757dcc94" have entirely different histories.
78f5415d9a
...
fe91f798ba
3 changed files with 0 additions and 64 deletions
|
@ -28,7 +28,6 @@ type Database interface {
|
||||||
GetAllUsersApplication() ([]string, error)
|
GetAllUsersApplication() ([]string, error)
|
||||||
GetProjectsForUser(username string) ([]types.Project, error)
|
GetProjectsForUser(username string) ([]types.Project, error)
|
||||||
GetAllProjects() ([]types.Project, error)
|
GetAllProjects() ([]types.Project, error)
|
||||||
GetProject(projectId int) (types.Project, error)
|
|
||||||
GetUserRole(username string, projectname string) (string, error)
|
GetUserRole(username string, projectname string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,12 +100,6 @@ func (d *Db) GetAllProjects() ([]types.Project, error) {
|
||||||
return projects, err
|
return projects, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Db) GetProject(projectId int) (types.Project, error) {
|
|
||||||
var project types.Project
|
|
||||||
err := d.Select(&project, "SELECT * FROM projects WHERE id = ?")
|
|
||||||
return project, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Db) AddTimeReport(projectName string, userName string, start time.Time, end time.Time) error { // WIP
|
func (d *Db) AddTimeReport(projectName string, userName string, start time.Time, end time.Time) error { // WIP
|
||||||
_, err := d.Exec(addTimeReport, userName, projectName, start, end)
|
_, err := d.Exec(addTimeReport, userName, projectName, start, end)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -343,38 +343,3 @@ func TestGetProjectsForUser(t *testing.T) {
|
||||||
t.Error("GetProjectsForUser failed: expected 1, got", len(projects))
|
t.Error("GetProjectsForUser failed: expected 1, got", len(projects))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddProject(t *testing.T) {
|
|
||||||
db, err := setupState()
|
|
||||||
if err != nil {
|
|
||||||
t.Error("setupState failed:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.AddUser("testuser", "password")
|
|
||||||
if err != nil {
|
|
||||||
t.Error("AddUser failed:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.AddProject("testproject", "description", "testuser")
|
|
||||||
if err != nil {
|
|
||||||
t.Error("AddProject failed:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve the added project to verify its existence
|
|
||||||
projects, err := db.GetAllProjects()
|
|
||||||
if err != nil {
|
|
||||||
t.Error("GetAllProjects failed:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the project was added successfully
|
|
||||||
found := false
|
|
||||||
for _, project := range projects {
|
|
||||||
if project.Name == "testproject" {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
t.Error("Added project not found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
"ttime/internal/database"
|
"ttime/internal/database"
|
||||||
"ttime/internal/types"
|
"ttime/internal/types"
|
||||||
|
@ -226,24 +225,3 @@ func (gs *GState) ProjectRoleChange(c *fiber.Ctx) error {
|
||||||
// Return a success message
|
// Return a success message
|
||||||
return c.SendStatus(fiber.StatusOK)
|
return c.SendStatus(fiber.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProject retrieves a specific project by its ID
|
|
||||||
func (gs *GState) GetProject(c *fiber.Ctx) error {
|
|
||||||
// Extract the project ID from the request parameters or body
|
|
||||||
projectID := c.Params("projectID")
|
|
||||||
|
|
||||||
// Parse the project ID into an integer
|
|
||||||
projectIDInt, err := strconv.Atoi(projectID)
|
|
||||||
if err != nil {
|
|
||||||
return c.Status(400).SendString("Invalid project ID")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the project from the database by its ID
|
|
||||||
project, err := gs.Db.GetProject(projectIDInt)
|
|
||||||
if err != nil {
|
|
||||||
return c.Status(500).SendString(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the project as JSON
|
|
||||||
return c.JSON(project)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue