Documentation
¶
Index ¶
- Variables
- type Core
- func (c Core) Create(ctx context.Context, nt NewTimeEntry, userID string, now time.Time) (TimeEntry, error)
- func (c Core) Delete(ctx context.Context, timeEntryID string) error
- func (c Core) QueryByID(ctx context.Context, timeEntryID string) (TimeEntry, error)
- func (c Core) QueryDash(ctx context.Context, UserID string) ([]TimeEntry, error)
- func (c Core) QueryRange(ctx context.Context, userID string, pageNumber, rowsPerPage int, ...) ([]TimeEntry, error)
- func (c Core) QueryRunning(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]TimeEntry, error)
- func (c Core) Start(ctx context.Context, st StartTimeEntry, userID string, now time.Time) (TimeEntry, error)
- func (c Core) Stop(ctx context.Context, TimeEntryID string, now time.Time) (TimeEntry, error)
- func (c Core) SyncProjectTime(ctx context.Context, projectID string, now time.Time) error
- func (c Core) SyncTaskTime(ctx context.Context, taskID string, now time.Time) error
- func (c Core) Update(ctx context.Context, TimeEntryID string, ut UpdateTimeEntry, now time.Time) error
- func (c Core) UpdateTags(ctx context.Context, TimeEntryID string, ut UpdateTimeEntryTags, now time.Time) error
- type NewTimeEntry
- type StartTimeEntry
- type TimeEntry
- type UpdateTimeEntry
- type UpdateTimeEntryTags
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("user not found") ErrInvalidID = errors.New("ID is not in its proper form") )
Set of error variables for CRUD operations.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for user access.
func NewCore ¶
func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB) Core
NewCore constructs a core for user api access.
func (Core) Create ¶
func (c Core) Create(ctx context.Context, nt NewTimeEntry, userID string, now time.Time) (TimeEntry, error)
Create inserts a new time entry into the database.
func (Core) QueryRange ¶
func (c Core) QueryRange(ctx context.Context, userID string, pageNumber, rowsPerPage int, start, end time.Time) ([]TimeEntry, error)
QueryRange retrieves a list of existing time entry from the database.
func (Core) QueryRunning ¶
func (c Core) QueryRunning(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]TimeEntry, error)
QueryRunning retrieves a list of existing time entry from the database.
func (Core) Start ¶
func (c Core) Start(ctx context.Context, st StartTimeEntry, userID string, now time.Time) (TimeEntry, error)
Start inserts a new time entry into the database.
func (Core) SyncProjectTime ¶
SyncProjectTime sync the specified project time from the database.
func (Core) SyncTaskTime ¶
SyncTaskTime sync the specified task time from the database.
func (Core) Update ¶
func (c Core) Update(ctx context.Context, TimeEntryID string, ut UpdateTimeEntry, now time.Time) error
Update replaces a time_entry document in the database.
func (Core) UpdateTags ¶
func (c Core) UpdateTags(ctx context.Context, TimeEntryID string, ut UpdateTimeEntryTags, now time.Time) error
UpdateTags replaces a time_entry document in the database.
type NewTimeEntry ¶
type NewTimeEntry struct {
Description string `json:"description"`
Wid string `json:"wid"`
Pid string `json:"pid"`
Tid string `json:"tid"`
Billable bool `json:"billable"`
Start time.Time `json:"start" validate:"required"`
Stop time.Time `json:"stop"`
Duration time.Duration `json:"duration" validate:"required"`
CreatedWith string `json:"created_with" validate:"required"`
Tags []string `json:"tags"`
DurOnly bool `json:"dur_only"`
}
NewTimeEntry contains information needed to create a new time_entry.
type StartTimeEntry ¶
type StartTimeEntry struct {
Description string `json:"description"`
Wid string `json:"wid"`
Pid string `json:"pid"`
Tid string `json:"tid"`
Billable bool `json:"billable"`
CreatedWith string `json:"created_with" validate:"required"`
Tags []string `json:"tags"`
DurOnly bool `json:"dur_only"`
}
StartTimeEntry contains information needed to start a new time_entry.
type TimeEntry ¶
type TimeEntry struct {
ID string `json:"id"`
Description string `json:"description"`
Uid string `json:"uid"`
Wid string `json:"wid"`
Pid string `json:"pid"`
Tid string `json:"tid"`
Billable bool `json:"billable"`
Start time.Time `json:"start"`
Stop time.Time `json:"stop"`
Duration time.Duration `json:"duration"`
CreatedWith string `json:"created_with"`
Tags []string `json:"tags"`
DurOnly bool `json:"dur_only"`
DateCreated time.Time `json:"date_created"`
DateUpdated time.Time `json:"date_updated"`
}
TimeEntry represents an individual time_entry.
type UpdateTimeEntry ¶
type UpdateTimeEntry struct {
Description *string `json:"description"`
Billable *bool `json:"billable"`
Start *time.Time `json:"start"`
Stop *time.Time `json:"stop"`
CreatedWith *string `json:"created_with"`
Tags []string `json:"tags"`
DurOnly *bool `json:"dur_only"`
}
UpdateTimeEntry defines what information may be provided to modify an existing time_entry. All fields are optional so time_entry can send just the fields they want changed. It uses pointer fields ,so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types ,but we make exceptions around marshalling/unmarshalling.
type UpdateTimeEntryTags ¶
type UpdateTimeEntryTags struct {
Tags []string `json:"tags" validate:"required"`
TagMode string `json:"tag_mode" validate:"required"`
}
UpdateTimeEntryTags contains information needed to update bulk of time_entry tags.