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.

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

package store

import (
	"context"

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

const getRoomDocumentCommentResolutionAuthority = `-- name: GetRoomDocumentCommentResolutionAuthority :one
SELECT thread.id AS thread_id,thread.document_id,thread.tenant_id,thread.room_id,
       caller.id AS actor_id
FROM room_document_comment_threads thread
JOIN documents document
  ON document.id=thread.document_id AND document.tenant_id=thread.tenant_id
 AND document.status='active'
JOIN actors caller
  ON caller.tenant_id=thread.tenant_id
 AND caller.account_id=$1::text
 AND caller.kind='human'
WHERE thread.id=$2::text
  AND thread.anchor_status<>'orphaned'
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_v2(
      $1::text,thread.document_id
  ) access
  WHERE access.tenant_id=thread.tenant_id AND access.can_read)
FOR UPDATE OF thread
`

type GetRoomDocumentCommentResolutionAuthorityParams struct {
	AccountID string `json:"account_id"`
	ThreadID  string `json:"thread_id"`
}

type GetRoomDocumentCommentResolutionAuthorityRow struct {
	ThreadID   string      `json:"thread_id"`
	DocumentID string      `json:"document_id"`
	TenantID   string      `json:"tenant_id"`
	RoomID     pgtype.Text `json:"room_id"`
	ActorID    string      `json:"actor_id"`
}

func (q *Queries) GetRoomDocumentCommentResolutionAuthority(ctx context.Context, arg GetRoomDocumentCommentResolutionAuthorityParams) (GetRoomDocumentCommentResolutionAuthorityRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentResolutionAuthority, arg.AccountID, arg.ThreadID)
	var i GetRoomDocumentCommentResolutionAuthorityRow
	err := row.Scan(
		&i.ThreadID,
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
		&i.ActorID,
	)
	return i, err
}

const reopenRoomDocumentCommentThread = `-- name: ReopenRoomDocumentCommentThread :execrows
UPDATE room_document_comment_threads
SET resolved_by_actor_id=NULL,resolved_at=NULL,updated_at=now()
WHERE id=$1::text
  AND resolved_at IS NOT NULL
`

func (q *Queries) ReopenRoomDocumentCommentThread(ctx context.Context, threadID string) (int64, error) {
	result, err := q.db.Exec(ctx, reopenRoomDocumentCommentThread, threadID)
	if err != nil {
		return 0, err
	}
	return result.RowsAffected(), nil
}

const resolveRoomDocumentCommentThread = `-- name: ResolveRoomDocumentCommentThread :execrows
UPDATE room_document_comment_threads
SET resolved_by_actor_id=$1::text,
    resolved_at=now(),updated_at=now()
WHERE id=$2::text
  AND resolved_at IS NULL
`

type ResolveRoomDocumentCommentThreadParams struct {
	ResolvedByActorID string `json:"resolved_by_actor_id"`
	ThreadID          string `json:"thread_id"`
}

func (q *Queries) ResolveRoomDocumentCommentThread(ctx context.Context, arg ResolveRoomDocumentCommentThreadParams) (int64, error) {
	result, err := q.db.Exec(ctx, resolveRoomDocumentCommentThread, arg.ResolvedByActorID, arg.ThreadID)
	if err != nil {
		return 0, err
	}
	return result.RowsAffected(), nil
}