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.
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: message_context_feedback.sql
package store
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const listMessageContextsForCreate = `-- name: ListMessageContextsForCreate :many
SELECT message.id AS context_message_id,message.body,message.segments,message.created_at,
author.id AS author_actor_id,author.tenant_id AS author_tenant_id,
author.kind AS author_kind,author.display_name AS author_display_name,
author.account_id AS author_account_id,author.handle AS author_handle,
author.created_at AS author_created_at
FROM messages message
JOIN actors author
ON author.id=message.author_actor_id AND author.tenant_id=message.tenant_id
WHERE message.room_id=$1::text
AND message.id=ANY($2::text[])
AND message.message_kind<>'room_notice'
ORDER BY array_position($2::text[],message.id)
`
type ListMessageContextsForCreateParams struct {
RoomID string `json:"room_id"`
ContextMessageIds []string `json:"context_message_ids"`
}
type ListMessageContextsForCreateRow struct {
ContextMessageID string `json:"context_message_id"`
Body string `json:"body"`
Segments []byte `json:"segments"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
AuthorActorID string `json:"author_actor_id"`
AuthorTenantID string `json:"author_tenant_id"`
AuthorKind string `json:"author_kind"`
AuthorDisplayName string `json:"author_display_name"`
AuthorAccountID pgtype.Text `json:"author_account_id"`
AuthorHandle pgtype.Text `json:"author_handle"`
AuthorCreatedAt pgtype.Timestamptz `json:"author_created_at"`
}
func (q *Queries) ListMessageContextsForCreate(ctx context.Context, arg ListMessageContextsForCreateParams) ([]ListMessageContextsForCreateRow, error) {
rows, err := q.db.Query(ctx, listMessageContextsForCreate, arg.RoomID, arg.ContextMessageIds)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListMessageContextsForCreateRow{}
for rows.Next() {
var i ListMessageContextsForCreateRow
if err := rows.Scan(
&i.ContextMessageID,
&i.Body,
&i.Segments,
&i.CreatedAt,
&i.AuthorActorID,
&i.AuthorTenantID,
&i.AuthorKind,
&i.AuthorDisplayName,
&i.AuthorAccountID,
&i.AuthorHandle,
&i.AuthorCreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listMessageContextsForMessages = `-- name: ListMessageContextsForMessages :many
SELECT message.id AS message_id,(context.ordinality-1)::smallint AS position,
source.id AS context_message_id,source.message_kind AS context_message_kind,
source.body,source.segments,source.created_at,
author.id AS author_actor_id,author.tenant_id AS author_tenant_id,
author.kind AS author_kind,author.display_name AS author_display_name,
author.account_id AS author_account_id,author.handle AS author_handle,
author.created_at AS author_created_at
FROM messages message
CROSS JOIN LATERAL unnest(message.context_message_ids) WITH ORDINALITY context(context_message_id,ordinality)
JOIN messages source
ON source.id=context.context_message_id
AND source.tenant_id=message.tenant_id
AND source.room_id=message.room_id
JOIN actors author
ON author.id=source.author_actor_id AND author.tenant_id=source.tenant_id
WHERE message.id=ANY($1::text[])
ORDER BY array_position($1::text[],message.id),context.ordinality
`
type ListMessageContextsForMessagesRow struct {
MessageID string `json:"message_id"`
Position int16 `json:"position"`
ContextMessageID string `json:"context_message_id"`
ContextMessageKind string `json:"context_message_kind"`
Body string `json:"body"`
Segments []byte `json:"segments"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
AuthorActorID string `json:"author_actor_id"`
AuthorTenantID string `json:"author_tenant_id"`
AuthorKind string `json:"author_kind"`
AuthorDisplayName string `json:"author_display_name"`
AuthorAccountID pgtype.Text `json:"author_account_id"`
AuthorHandle pgtype.Text `json:"author_handle"`
AuthorCreatedAt pgtype.Timestamptz `json:"author_created_at"`
}
func (q *Queries) ListMessageContextsForMessages(ctx context.Context, messageIds []string) ([]ListMessageContextsForMessagesRow, error) {
rows, err := q.db.Query(ctx, listMessageContextsForMessages, messageIds)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListMessageContextsForMessagesRow{}
for rows.Next() {
var i ListMessageContextsForMessagesRow
if err := rows.Scan(
&i.MessageID,
&i.Position,
&i.ContextMessageID,
&i.ContextMessageKind,
&i.Body,
&i.Segments,
&i.CreatedAt,
&i.AuthorActorID,
&i.AuthorTenantID,
&i.AuthorKind,
&i.AuthorDisplayName,
&i.AuthorAccountID,
&i.AuthorHandle,
&i.AuthorCreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}