Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

4.2 KB
Raw Blame
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0
// source: pocket_note.sql

package store

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const deletePocketNote = `-- name: DeletePocketNote :exec
DELETE FROM pocket_notes
WHERE tenant_id=$1::text
  AND owner_actor_id=$2::text
  AND note_date=$3::date
`

type DeletePocketNoteParams struct {
	TenantID     string      `json:"tenant_id"`
	OwnerActorID string      `json:"owner_actor_id"`
	NoteDate     pgtype.Date `json:"note_date"`
}

func (q *Queries) DeletePocketNote(ctx context.Context, arg DeletePocketNoteParams) error {
	_, err := q.db.Exec(ctx, deletePocketNote, arg.TenantID, arg.OwnerActorID, arg.NoteDate)
	return err
}

const getPocketNoteUpdatedAt = `-- name: GetPocketNoteUpdatedAt :one
SELECT updated_at
FROM pocket_notes
WHERE tenant_id=$1::text
  AND owner_actor_id=$2::text
  AND note_date=$3::date
`

type GetPocketNoteUpdatedAtParams struct {
	TenantID     string      `json:"tenant_id"`
	OwnerActorID string      `json:"owner_actor_id"`
	NoteDate     pgtype.Date `json:"note_date"`
}

// When a day's page last changed; a cleared page has no row.
func (q *Queries) GetPocketNoteUpdatedAt(ctx context.Context, arg GetPocketNoteUpdatedAtParams) (pgtype.Timestamptz, error) {
	row := q.db.QueryRow(ctx, getPocketNoteUpdatedAt, arg.TenantID, arg.OwnerActorID, arg.NoteDate)
	var updated_at pgtype.Timestamptz
	err := row.Scan(&updated_at)
	return updated_at, err
}

const hidePocketNote = `-- name: HidePocketNote :exec
UPDATE pocket_notes
SET hidden_at=clock_timestamp()
WHERE tenant_id=$1::text
  AND owner_actor_id=$2::text
  AND note_date=$3::date
  AND hidden_at IS NULL
`

type HidePocketNoteParams struct {
	TenantID     string      `json:"tenant_id"`
	OwnerActorID string      `json:"owner_actor_id"`
	NoteDate     pgtype.Date `json:"note_date"`
}

func (q *Queries) HidePocketNote(ctx context.Context, arg HidePocketNoteParams) error {
	_, err := q.db.Exec(ctx, hidePocketNote, arg.TenantID, arg.OwnerActorID, arg.NoteDate)
	return err
}

const listPocketNotes = `-- name: ListPocketNotes :many
SELECT note_date,body,updated_at
FROM pocket_notes
WHERE tenant_id=$1::text
  AND owner_actor_id=$2::text
  AND hidden_at IS NULL
  AND ($3::date IS NULL OR note_date<$3::date)
ORDER BY note_date DESC
LIMIT $4::integer
`

type ListPocketNotesParams struct {
	TenantID     string      `json:"tenant_id"`
	OwnerActorID string      `json:"owner_actor_id"`
	BeforeDate   pgtype.Date `json:"before_date"`
	RowLimit     int32       `json:"row_limit"`
}

type ListPocketNotesRow struct {
	NoteDate  pgtype.Date        `json:"note_date"`
	Body      string             `json:"body"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) ListPocketNotes(ctx context.Context, arg ListPocketNotesParams) ([]ListPocketNotesRow, error) {
	rows, err := q.db.Query(ctx, listPocketNotes,
		arg.TenantID,
		arg.OwnerActorID,
		arg.BeforeDate,
		arg.RowLimit,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListPocketNotesRow{}
	for rows.Next() {
		var i ListPocketNotesRow
		if err := rows.Scan(&i.NoteDate, &i.Body, &i.UpdatedAt); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const upsertPocketNote = `-- name: UpsertPocketNote :one
INSERT INTO pocket_notes(tenant_id,owner_actor_id,note_date,body)
VALUES($1::text,$2::text,$3::date,$4::text)
ON CONFLICT (tenant_id,owner_actor_id,note_date) DO UPDATE
SET body=excluded.body,updated_at=clock_timestamp()
RETURNING note_date,body,updated_at
`

type UpsertPocketNoteParams struct {
	TenantID     string      `json:"tenant_id"`
	OwnerActorID string      `json:"owner_actor_id"`
	NoteDate     pgtype.Date `json:"note_date"`
	Body         string      `json:"body"`
}

type UpsertPocketNoteRow struct {
	NoteDate  pgtype.Date        `json:"note_date"`
	Body      string             `json:"body"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) UpsertPocketNote(ctx context.Context, arg UpsertPocketNoteParams) (UpsertPocketNoteRow, error) {
	row := q.db.QueryRow(ctx, upsertPocketNote,
		arg.TenantID,
		arg.OwnerActorID,
		arg.NoteDate,
		arg.Body,
	)
	var i UpsertPocketNoteRow
	err := row.Scan(&i.NoteDate, &i.Body, &i.UpdatedAt)
	return i, err
}