// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.13.0 // source: sprint.sql package mysqlcore import ( "context" "database/sql" "time" ) const deleteAllScopeSprints = `-- name: DeleteAllScopeSprints :exec DELETE FROM sprint WHERE scope_id = ? ` func (q *Queries) DeleteAllScopeSprints(ctx context.Context, scopeID int) error { _, err := q.exec(ctx, q.deleteAllScopeSprintsStmt, deleteAllScopeSprints, scopeID) return err } const deleteAllSprintParts = `-- name: DeleteAllSprintParts :exec DELETE FROM sprint_part WHERE sprint_id = ? ` func (q *Queries) DeleteAllSprintParts(ctx context.Context, sprintID int) error { _, err := q.exec(ctx, q.deleteAllSprintPartsStmt, deleteAllSprintParts, sprintID) return err } const deleteSprint = `-- name: DeleteSprint :exec DELETE FROM sprint WHERE id = ? ` func (q *Queries) DeleteSprint(ctx context.Context, id int) error { _, err := q.exec(ctx, q.deleteSprintStmt, deleteSprint, id) return err } const deleteSprintPart = `-- name: DeleteSprintPart :exec DELETE FROM sprint_part WHERE sprint_id = ? AND object_id = ? ` type DeleteSprintPartParams struct { SprintID int ObjectID int } func (q *Queries) DeleteSprintPart(ctx context.Context, arg DeleteSprintPartParams) error { _, err := q.exec(ctx, q.deleteSprintPartStmt, deleteSprintPart, arg.SprintID, arg.ObjectID) return err } const getSprint = `-- name: GetSprint :one SELECT id, scope_id, name, description, from_time, to_time, is_timed, is_coarse, is_unweighted, kind, aggregate_name, aggregate_required FROM sprint WHERE id = ? AND scope_id = ? ` type GetSprintParams struct { ID int ScopeID int } func (q *Queries) GetSprint(ctx context.Context, arg GetSprintParams) (Sprint, error) { row := q.queryRow(ctx, q.getSprintStmt, getSprint, arg.ID, arg.ScopeID) var i Sprint err := row.Scan( &i.ID, &i.ScopeID, &i.Name, &i.Description, &i.FromTime, &i.ToTime, &i.IsTimed, &i.IsCoarse, &i.IsUnweighted, &i.Kind, &i.AggregateName, &i.AggregateRequired, ) return i, err } const insertSprint = `-- name: InsertSprint :execresult INSERT INTO sprint ( scope_id, name, description, kind, from_time, to_time, is_timed, is_coarse, aggregate_name, aggregate_required, is_unweighted ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ` type InsertSprintParams struct { ScopeID int Name string Description string Kind int FromTime time.Time ToTime time.Time IsTimed bool IsCoarse bool AggregateName string AggregateRequired int IsUnweighted bool } func (q *Queries) InsertSprint(ctx context.Context, arg InsertSprintParams) (sql.Result, error) { return q.exec(ctx, q.insertSprintStmt, insertSprint, arg.ScopeID, arg.Name, arg.Description, arg.Kind, arg.FromTime, arg.ToTime, arg.IsTimed, arg.IsCoarse, arg.AggregateName, arg.AggregateRequired, arg.IsUnweighted, ) } const listSprintParts = `-- name: ListSprintParts :many SELECT sprint_id, object_id, required FROM sprint_part WHERE sprint_id = ? ` func (q *Queries) ListSprintParts(ctx context.Context, sprintID int) ([]SprintPart, error) { rows, err := q.query(ctx, q.listSprintPartsStmt, listSprintParts, sprintID) if err != nil { return nil, err } defer rows.Close() items := []SprintPart{} for rows.Next() { var i SprintPart if err := rows.Scan(&i.SprintID, &i.ObjectID, &i.Required); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listSprintsAt = `-- name: ListSprintsAt :many SELECT id, scope_id, name, description, from_time, to_time, is_timed, is_coarse, is_unweighted, kind, aggregate_name, aggregate_required FROM sprint WHERE scope_id = ? AND from_time <= ? AND to_time > ? ` type ListSprintsAtParams struct { ScopeID int Time time.Time } func (q *Queries) ListSprintsAt(ctx context.Context, arg ListSprintsAtParams) ([]Sprint, error) { rows, err := q.query(ctx, q.listSprintsAtStmt, listSprintsAt, arg.ScopeID, arg.Time, arg.Time) if err != nil { return nil, err } defer rows.Close() items := []Sprint{} for rows.Next() { var i Sprint if err := rows.Scan( &i.ID, &i.ScopeID, &i.Name, &i.Description, &i.FromTime, &i.ToTime, &i.IsTimed, &i.IsCoarse, &i.IsUnweighted, &i.Kind, &i.AggregateName, &i.AggregateRequired, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listSprintsBetween = `-- name: ListSprintsBetween :many SELECT id, scope_id, name, description, from_time, to_time, is_timed, is_coarse, is_unweighted, kind, aggregate_name, aggregate_required FROM sprint WHERE scope_id = ? AND ( -- from time is within from..to (from_time <= ? AND to_time > ?) -- or to time is within from..to OR (from_time <= ? AND to_time > ?) -- or from and to time are on each their side of from..to OR (from_time < ? AND to_time >= ?) ) ` type ListSprintsBetweenParams struct { ScopeID int FromTime time.Time ToTime time.Time FromTime_2 time.Time ToTime_2 time.Time FromTime_3 time.Time ToTime_3 time.Time } func (q *Queries) ListSprintsBetween(ctx context.Context, arg ListSprintsBetweenParams) ([]Sprint, error) { rows, err := q.query(ctx, q.listSprintsBetweenStmt, listSprintsBetween, arg.ScopeID, arg.FromTime, arg.ToTime, arg.FromTime_2, arg.ToTime_2, arg.FromTime_3, arg.ToTime_3, ) if err != nil { return nil, err } defer rows.Close() items := []Sprint{} for rows.Next() { var i Sprint if err := rows.Scan( &i.ID, &i.ScopeID, &i.Name, &i.Description, &i.FromTime, &i.ToTime, &i.IsTimed, &i.IsCoarse, &i.IsUnweighted, &i.Kind, &i.AggregateName, &i.AggregateRequired, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const replaceSprintPart = `-- name: ReplaceSprintPart :exec REPLACE INTO sprint_part (sprint_id, object_id, required) VALUES (?, ?, ?) ` type ReplaceSprintPartParams struct { SprintID int ObjectID int Required int } func (q *Queries) ReplaceSprintPart(ctx context.Context, arg ReplaceSprintPartParams) error { _, err := q.exec(ctx, q.replaceSprintPartStmt, replaceSprintPart, arg.SprintID, arg.ObjectID, arg.Required) return err } const updateSprint = `-- name: UpdateSprint :exec UPDATE sprint SET name = ?, description = ?, from_time = ?, to_time = ?, is_timed = ?, is_coarse = ?, aggregate_name = ?, aggregate_required = ? WHERE id = ? ` type UpdateSprintParams struct { Name string Description string FromTime time.Time ToTime time.Time IsTimed bool IsCoarse bool AggregateName string AggregateRequired int ID int } func (q *Queries) UpdateSprint(ctx context.Context, arg UpdateSprintParams) error { _, err := q.exec(ctx, q.updateSprintStmt, updateSprint, arg.Name, arg.Description, arg.FromTime, arg.ToTime, arg.IsTimed, arg.IsCoarse, arg.AggregateName, arg.AggregateRequired, arg.ID, ) return err }