Fix BASE_URL config loading, add tasks/projects; robust .env path resolution
- Config: try ENV_FILE, .env, ../.env for loading; trim trailing slash from BaseURL - Log BASE_URL at server startup for verification - .env.example: document BASE_URL - Tasks, projects, tags, migrations and related API/handlers Made-with: Cursor
This commit is contained in:
164
internal/repository/task_reminders.sql.go
Normal file
164
internal/repository/task_reminders.sql.go
Normal file
@@ -0,0 +1,164 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: task_reminders.sql
|
||||
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const createTaskReminder = `-- name: CreateTaskReminder :one
|
||||
INSERT INTO task_reminders (id, task_id, type, config, scheduled_at)
|
||||
VALUES ($1, $2, $3, COALESCE($4, '{}'), $5)
|
||||
RETURNING id, task_id, type, config, scheduled_at, created_at
|
||||
`
|
||||
|
||||
type CreateTaskReminderParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
TaskID pgtype.UUID `json:"task_id"`
|
||||
Type string `json:"type"`
|
||||
Column4 interface{} `json:"column_4"`
|
||||
ScheduledAt pgtype.Timestamptz `json:"scheduled_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTaskReminder(ctx context.Context, arg CreateTaskReminderParams) (TaskReminder, error) {
|
||||
row := q.db.QueryRow(ctx, createTaskReminder,
|
||||
arg.ID,
|
||||
arg.TaskID,
|
||||
arg.Type,
|
||||
arg.Column4,
|
||||
arg.ScheduledAt,
|
||||
)
|
||||
var i TaskReminder
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TaskID,
|
||||
&i.Type,
|
||||
&i.Config,
|
||||
&i.ScheduledAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteTaskReminder = `-- name: DeleteTaskReminder :exec
|
||||
DELETE FROM task_reminders WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTaskReminder(ctx context.Context, id pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, deleteTaskReminder, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteTaskRemindersByTask = `-- name: DeleteTaskRemindersByTask :exec
|
||||
DELETE FROM task_reminders WHERE task_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteTaskRemindersByTask(ctx context.Context, taskID pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, deleteTaskRemindersByTask, taskID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getTaskReminderByID = `-- name: GetTaskReminderByID :one
|
||||
SELECT id, task_id, type, config, scheduled_at, created_at FROM task_reminders
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTaskReminderByID(ctx context.Context, id pgtype.UUID) (TaskReminder, error) {
|
||||
row := q.db.QueryRow(ctx, getTaskReminderByID, id)
|
||||
var i TaskReminder
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TaskID,
|
||||
&i.Type,
|
||||
&i.Config,
|
||||
&i.ScheduledAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listTaskReminders = `-- name: ListTaskReminders :many
|
||||
SELECT id, task_id, type, config, scheduled_at, created_at FROM task_reminders
|
||||
WHERE task_id = $1
|
||||
ORDER BY scheduled_at ASC
|
||||
`
|
||||
|
||||
func (q *Queries) ListTaskReminders(ctx context.Context, taskID pgtype.UUID) ([]TaskReminder, error) {
|
||||
rows, err := q.db.Query(ctx, listTaskReminders, taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []TaskReminder{}
|
||||
for rows.Next() {
|
||||
var i TaskReminder
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.TaskID,
|
||||
&i.Type,
|
||||
&i.Config,
|
||||
&i.ScheduledAt,
|
||||
&i.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listTaskRemindersDueBefore = `-- name: ListTaskRemindersDueBefore :many
|
||||
SELECT tr.id, tr.task_id, tr.type, tr.config, tr.scheduled_at, tr.created_at, t.owner_id, t.title
|
||||
FROM task_reminders tr
|
||||
JOIN tasks t ON t.id = tr.task_id
|
||||
WHERE tr.scheduled_at <= $1
|
||||
AND t.deleted_at IS NULL
|
||||
`
|
||||
|
||||
type ListTaskRemindersDueBeforeRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
TaskID pgtype.UUID `json:"task_id"`
|
||||
Type string `json:"type"`
|
||||
Config []byte `json:"config"`
|
||||
ScheduledAt pgtype.Timestamptz `json:"scheduled_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListTaskRemindersDueBefore(ctx context.Context, scheduledAt pgtype.Timestamptz) ([]ListTaskRemindersDueBeforeRow, error) {
|
||||
rows, err := q.db.Query(ctx, listTaskRemindersDueBefore, scheduledAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []ListTaskRemindersDueBeforeRow{}
|
||||
for rows.Next() {
|
||||
var i ListTaskRemindersDueBeforeRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.TaskID,
|
||||
&i.Type,
|
||||
&i.Config,
|
||||
&i.ScheduledAt,
|
||||
&i.CreatedAt,
|
||||
&i.OwnerID,
|
||||
&i.Title,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user