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.7 KB
Raw Blame
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0
// source: work_item_room.sql

package store

import (
	"context"

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

const createWorkItemRoomActivity = `-- name: CreateWorkItemRoomActivity :one
INSERT INTO work_item_activities(
    id, work_item_id, tenant_id, kind, actor_id, room_id
)
VALUES ($1, $2, $3, 'work_room_created', $4, $5)
RETURNING id, work_item_id, tenant_id, kind, actor_id, from_state, to_state,
          target_actor_id, comment_id, room_id, details, occurred_at
`

type CreateWorkItemRoomActivityParams struct {
	ID         string      `json:"id"`
	WorkItemID string      `json:"work_item_id"`
	TenantID   string      `json:"tenant_id"`
	ActorID    string      `json:"actor_id"`
	RoomID     pgtype.Text `json:"room_id"`
}

type CreateWorkItemRoomActivityRow struct {
	ID            string             `json:"id"`
	WorkItemID    string             `json:"work_item_id"`
	TenantID      string             `json:"tenant_id"`
	Kind          string             `json:"kind"`
	ActorID       string             `json:"actor_id"`
	FromState     pgtype.Text        `json:"from_state"`
	ToState       pgtype.Text        `json:"to_state"`
	TargetActorID pgtype.Text        `json:"target_actor_id"`
	CommentID     pgtype.Text        `json:"comment_id"`
	RoomID        pgtype.Text        `json:"room_id"`
	Details       []byte             `json:"details"`
	OccurredAt    pgtype.Timestamptz `json:"occurred_at"`
}

func (q *Queries) CreateWorkItemRoomActivity(ctx context.Context, arg CreateWorkItemRoomActivityParams) (CreateWorkItemRoomActivityRow, error) {
	row := q.db.QueryRow(ctx, createWorkItemRoomActivity,
		arg.ID,
		arg.WorkItemID,
		arg.TenantID,
		arg.ActorID,
		arg.RoomID,
	)
	var i CreateWorkItemRoomActivityRow
	err := row.Scan(
		&i.ID,
		&i.WorkItemID,
		&i.TenantID,
		&i.Kind,
		&i.ActorID,
		&i.FromState,
		&i.ToState,
		&i.TargetActorID,
		&i.CommentID,
		&i.RoomID,
		&i.Details,
		&i.OccurredAt,
	)
	return i, err
}

const createWorkItemRoomLink = `-- name: CreateWorkItemRoomLink :one
INSERT INTO work_item_room_links(
    work_item_id, tenant_id, link_type, room_id, origin_message_id, linked_by_actor_id
)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING work_item_id, tenant_id, link_type, room_id, origin_message_id,
          linked_by_actor_id, created_at
`

type CreateWorkItemRoomLinkParams struct {
	WorkItemID      string      `json:"work_item_id"`
	TenantID        string      `json:"tenant_id"`
	LinkType        string      `json:"link_type"`
	RoomID          string      `json:"room_id"`
	OriginMessageID pgtype.Text `json:"origin_message_id"`
	LinkedByActorID string      `json:"linked_by_actor_id"`
}

func (q *Queries) CreateWorkItemRoomLink(ctx context.Context, arg CreateWorkItemRoomLinkParams) (WorkItemRoomLink, error) {
	row := q.db.QueryRow(ctx, createWorkItemRoomLink,
		arg.WorkItemID,
		arg.TenantID,
		arg.LinkType,
		arg.RoomID,
		arg.OriginMessageID,
		arg.LinkedByActorID,
	)
	var i WorkItemRoomLink
	err := row.Scan(
		&i.WorkItemID,
		&i.TenantID,
		&i.LinkType,
		&i.RoomID,
		&i.OriginMessageID,
		&i.LinkedByActorID,
		&i.CreatedAt,
	)
	return i, err
}

const getWorkItemRoomLink = `-- name: GetWorkItemRoomLink :one
SELECT work_item_id, tenant_id, link_type, room_id, origin_message_id,
       linked_by_actor_id, created_at
FROM work_item_room_links
WHERE work_item_id=$1 AND link_type=$2
`

type GetWorkItemRoomLinkParams struct {
	WorkItemID string `json:"work_item_id"`
	LinkType   string `json:"link_type"`
}

func (q *Queries) GetWorkItemRoomLink(ctx context.Context, arg GetWorkItemRoomLinkParams) (WorkItemRoomLink, error) {
	row := q.db.QueryRow(ctx, getWorkItemRoomLink, arg.WorkItemID, arg.LinkType)
	var i WorkItemRoomLink
	err := row.Scan(
		&i.WorkItemID,
		&i.TenantID,
		&i.LinkType,
		&i.RoomID,
		&i.OriginMessageID,
		&i.LinkedByActorID,
		&i.CreatedAt,
	)
	return i, err
}

const listWorkItemRoomLinksByItems = `-- name: ListWorkItemRoomLinksByItems :many
SELECT work_item_id, tenant_id, link_type, room_id, origin_message_id,
       linked_by_actor_id, created_at
FROM work_item_room_links
WHERE work_item_id=ANY($1::text[])
ORDER BY work_item_id, link_type
`

func (q *Queries) ListWorkItemRoomLinksByItems(ctx context.Context, workItemIds []string) ([]WorkItemRoomLink, error) {
	rows, err := q.db.Query(ctx, listWorkItemRoomLinksByItems, workItemIds)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []WorkItemRoomLink{}
	for rows.Next() {
		var i WorkItemRoomLink
		if err := rows.Scan(
			&i.WorkItemID,
			&i.TenantID,
			&i.LinkType,
			&i.RoomID,
			&i.OriginMessageID,
			&i.LinkedByActorID,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}