summaryrefslogtreecommitdiff
path: root/internal/actions
diff options
context:
space:
mode:
Diffstat (limited to 'internal/actions')
-rw-r--r--internal/actions/actions.go18
-rw-r--r--internal/actions/clients.go6
-rw-r--r--internal/actions/projects.go6
-rw-r--r--internal/actions/timer.go10
4 files changed, 20 insertions, 20 deletions
diff --git a/internal/actions/actions.go b/internal/actions/actions.go
index 5e2610a..727b474 100644
--- a/internal/actions/actions.go
+++ b/internal/actions/actions.go
@@ -2,6 +2,7 @@ package actions
import (
"context"
+
"punchcard/internal/queries"
)
@@ -11,24 +12,23 @@ type Actions interface {
PunchIn(ctx context.Context, client, project, description string, billableRate *float64) (*TimerSession, error)
PunchInMostRecent(ctx context.Context, description string, billableRate *float64) (*TimerSession, error)
PunchOut(ctx context.Context) (*TimerSession, error)
-
+
// Client operations
CreateClient(ctx context.Context, name, email string, billableRate *float64) (*queries.Client, error)
FindClient(ctx context.Context, nameOrID string) (*queries.Client, error)
-
- // Project operations
+
+ // Project operations
CreateProject(ctx context.Context, name, client string, billableRate *float64) (*queries.Project, error)
FindProject(ctx context.Context, nameOrID string) (*queries.Project, error)
}
// New creates a new Actions instance
func New(q *queries.Queries) Actions {
- return &actionsImpl{
- queries: q,
- }
+ return &actions{queries: q}
}
-// actionsImpl implements the Actions interface
-type actionsImpl struct {
+// actions implements the Actions interface
+type actions struct {
queries *queries.Queries
-} \ No newline at end of file
+}
+
diff --git a/internal/actions/clients.go b/internal/actions/clients.go
index bc77139..c71ef4a 100644
--- a/internal/actions/clients.go
+++ b/internal/actions/clients.go
@@ -12,7 +12,7 @@ import (
)
// CreateClient creates a new client with the given name and optional email/rate
-func (a *actionsImpl) CreateClient(ctx context.Context, name, email string, billableRate *float64) (*queries.Client, error) {
+func (a *actions) CreateClient(ctx context.Context, name, email string, billableRate *float64) (*queries.Client, error) {
// Parse name and email if name contains email format "Name <email>"
finalName, finalEmail := parseNameAndEmail(name, email)
@@ -40,7 +40,7 @@ func (a *actionsImpl) CreateClient(ctx context.Context, name, email string, bill
}
// FindClient finds a client by name or ID
-func (a *actionsImpl) FindClient(ctx context.Context, nameOrID string) (*queries.Client, error) {
+func (a *actions) FindClient(ctx context.Context, nameOrID string) (*queries.Client, error) {
// Parse as ID if possible, otherwise use 0
var idParam int64
if id, err := strconv.ParseInt(nameOrID, 10, 64); err == nil {
@@ -89,4 +89,4 @@ func parseNameAndEmail(nameArg, emailArg string) (string, string) {
return finalName, finalEmail
}
-var emailAndNameRegex = regexp.MustCompile(`^(.+?)<([^>]+@[^>]+)>$`) \ No newline at end of file
+var emailAndNameRegex = regexp.MustCompile(`^(.+?)<([^>]+@[^>]+)>$`)
diff --git a/internal/actions/projects.go b/internal/actions/projects.go
index f991728..21f5ef5 100644
--- a/internal/actions/projects.go
+++ b/internal/actions/projects.go
@@ -10,7 +10,7 @@ import (
)
// CreateProject creates a new project for the specified client
-func (a *actionsImpl) CreateProject(ctx context.Context, name, client string, billableRate *float64) (*queries.Project, error) {
+func (a *actions) CreateProject(ctx context.Context, name, client string, billableRate *float64) (*queries.Project, error) {
// Find the client first
clientRecord, err := a.FindClient(ctx, client)
if err != nil {
@@ -36,7 +36,7 @@ func (a *actionsImpl) CreateProject(ctx context.Context, name, client string, bi
}
// FindProject finds a project by name or ID
-func (a *actionsImpl) FindProject(ctx context.Context, nameOrID string) (*queries.Project, error) {
+func (a *actions) FindProject(ctx context.Context, nameOrID string) (*queries.Project, error) {
// Parse as ID if possible, otherwise use 0
var idParam int64
if id, err := strconv.ParseInt(nameOrID, 10, 64); err == nil {
@@ -61,4 +61,4 @@ func (a *actionsImpl) FindProject(ctx context.Context, nameOrID string) (*querie
default:
return nil, fmt.Errorf("%w: %s matches multiple projects", ErrAmbiguousProject, nameOrID)
}
-} \ No newline at end of file
+}
diff --git a/internal/actions/timer.go b/internal/actions/timer.go
index 58dbba2..5235a0a 100644
--- a/internal/actions/timer.go
+++ b/internal/actions/timer.go
@@ -11,7 +11,7 @@ import (
// PunchIn starts a timer for the specified client/project
// Use empty strings for client/project to use most recent entry
-func (a *actionsImpl) PunchIn(ctx context.Context, client, project, description string, billableRate *float64) (*TimerSession, error) {
+func (a *actions) PunchIn(ctx context.Context, client, project, description string, billableRate *float64) (*TimerSession, error) {
// If no client specified, delegate to PunchInMostRecent
if client == "" && project == "" {
session, err := a.PunchInMostRecent(ctx, description, billableRate)
@@ -119,7 +119,7 @@ func (a *actionsImpl) PunchIn(ctx context.Context, client, project, description
}
// PunchInMostRecent starts a timer copying the most recent time entry
-func (a *actionsImpl) PunchInMostRecent(ctx context.Context, description string, billableRate *float64) (*TimerSession, error) {
+func (a *actions) PunchInMostRecent(ctx context.Context, description string, billableRate *float64) (*TimerSession, error) {
// Get most recent entry
mostRecent, err := a.queries.GetMostRecentTimeEntry(ctx)
if err != nil {
@@ -219,7 +219,7 @@ func (a *actionsImpl) PunchInMostRecent(ctx context.Context, description string,
}
// PunchOut stops the active timer
-func (a *actionsImpl) PunchOut(ctx context.Context) (*TimerSession, error) {
+func (a *actions) PunchOut(ctx context.Context) (*TimerSession, error) {
stoppedEntry, err := a.queries.StopTimeEntry(ctx)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
@@ -264,7 +264,7 @@ func (a *actionsImpl) PunchOut(ctx context.Context) (*TimerSession, error) {
// Helper functions
-func (a *actionsImpl) createTimeEntry(ctx context.Context, clientID int64, projectID sql.NullInt64, description string, billableRate *float64) (*queries.TimeEntry, error) {
+func (a *actions) createTimeEntry(ctx context.Context, clientID int64, projectID sql.NullInt64, description string, billableRate *float64) (*queries.TimeEntry, error) {
var descParam sql.NullString
if description != "" {
descParam = sql.NullString{String: description, Valid: true}
@@ -339,4 +339,4 @@ func timeEntriesMatch(clientID int64, projectID sql.NullInt64, description strin
// regardless of what coalesced rate the active entry might have
return true
-} \ No newline at end of file
+}