2022-06-08 21:17:08 -07:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
2023-01-22 10:12:55 -08:00
|
|
|
// sqlc v1.16.0
|
2022-06-08 21:17:08 -07:00
|
|
|
// source: query.sql
|
|
|
|
|
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
const createArticle = `-- name: CreateArticle :exec
|
|
|
|
INSERT INTO Articles
|
|
|
|
(ID, SourceId, Tags, Title, Url, PubDate, Video, VideoHeight, VideoWidth, Thumbnail, Description, AuthorName, AuthorImage)
|
|
|
|
Values
|
|
|
|
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateArticleParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Sourceid uuid.UUID
|
|
|
|
Tags string
|
|
|
|
Title string
|
|
|
|
Url string
|
|
|
|
Pubdate time.Time
|
|
|
|
Video sql.NullString
|
|
|
|
Videoheight int32
|
|
|
|
Videowidth int32
|
|
|
|
Thumbnail string
|
|
|
|
Description string
|
|
|
|
Authorname sql.NullString
|
|
|
|
Authorimage sql.NullString
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) CreateArticle(ctx context.Context, arg CreateArticleParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createArticle,
|
|
|
|
arg.ID,
|
|
|
|
arg.Sourceid,
|
|
|
|
arg.Tags,
|
|
|
|
arg.Title,
|
|
|
|
arg.Url,
|
|
|
|
arg.Pubdate,
|
|
|
|
arg.Video,
|
|
|
|
arg.Videoheight,
|
|
|
|
arg.Videowidth,
|
|
|
|
arg.Thumbnail,
|
|
|
|
arg.Description,
|
|
|
|
arg.Authorname,
|
|
|
|
arg.Authorimage,
|
|
|
|
)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const createDiscordQueue = `-- name: CreateDiscordQueue :exec
|
|
|
|
Insert into DiscordQueue
|
|
|
|
(ID, ArticleId)
|
|
|
|
Values
|
|
|
|
($1, $2)
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateDiscordQueueParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Articleid uuid.UUID
|
|
|
|
}
|
|
|
|
|
|
|
|
// DiscordQueue
|
|
|
|
func (q *Queries) CreateDiscordQueue(ctx context.Context, arg CreateDiscordQueueParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createDiscordQueue, arg.ID, arg.Articleid)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const createDiscordWebHook = `-- name: CreateDiscordWebHook :exec
|
|
|
|
Insert Into DiscordWebHooks
|
2022-06-19 22:02:44 -07:00
|
|
|
(ID, Url, Server, Channel, Enabled)
|
2022-06-08 21:17:08 -07:00
|
|
|
Values
|
2022-06-19 22:02:44 -07:00
|
|
|
($1, $2, $3, $4, $5)
|
2022-06-08 21:17:08 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
type CreateDiscordWebHookParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Url string
|
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
Enabled bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// DiscordWebHooks
|
|
|
|
func (q *Queries) CreateDiscordWebHook(ctx context.Context, arg CreateDiscordWebHookParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createDiscordWebHook,
|
|
|
|
arg.ID,
|
|
|
|
arg.Url,
|
|
|
|
arg.Server,
|
|
|
|
arg.Channel,
|
|
|
|
arg.Enabled,
|
|
|
|
)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const createIcon = `-- name: CreateIcon :exec
|
|
|
|
|
|
|
|
INSERT INTO Icons
|
|
|
|
(ID, FileName, Site)
|
|
|
|
VALUES
|
|
|
|
($1,$2,$3)
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateIconParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Filename string
|
|
|
|
Site string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Icons
|
|
|
|
func (q *Queries) CreateIcon(ctx context.Context, arg CreateIconParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createIcon, arg.ID, arg.Filename, arg.Site)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const createSettings = `-- name: CreateSettings :one
|
|
|
|
|
|
|
|
Insert Into settings
|
|
|
|
(ID, Key, Value, OPTIONS)
|
|
|
|
Values
|
|
|
|
($1,$2,$3,$4)
|
|
|
|
RETURNING id, key, value, options
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateSettingsParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Key string
|
|
|
|
Value string
|
|
|
|
Options sql.NullString
|
|
|
|
}
|
|
|
|
|
|
|
|
// Settings
|
|
|
|
func (q *Queries) CreateSettings(ctx context.Context, arg CreateSettingsParams) (Setting, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, createSettings,
|
|
|
|
arg.ID,
|
|
|
|
arg.Key,
|
|
|
|
arg.Value,
|
|
|
|
arg.Options,
|
|
|
|
)
|
|
|
|
var i Setting
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Key,
|
|
|
|
&i.Value,
|
|
|
|
&i.Options,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const createSource = `-- name: CreateSource :exec
|
|
|
|
|
|
|
|
Insert Into Sources
|
|
|
|
(ID, Site, Name, Source, Type, Value, Enabled, Url, Tags)
|
|
|
|
Values
|
|
|
|
($1,$2,$3,$4,$5,$6,$7,$8,$9)
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateSourceParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Site string
|
|
|
|
Name string
|
|
|
|
Source string
|
|
|
|
Type string
|
|
|
|
Value sql.NullString
|
|
|
|
Enabled bool
|
|
|
|
Url string
|
|
|
|
Tags string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sources
|
|
|
|
func (q *Queries) CreateSource(ctx context.Context, arg CreateSourceParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createSource,
|
|
|
|
arg.ID,
|
|
|
|
arg.Site,
|
|
|
|
arg.Name,
|
|
|
|
arg.Source,
|
|
|
|
arg.Type,
|
|
|
|
arg.Value,
|
|
|
|
arg.Enabled,
|
|
|
|
arg.Url,
|
|
|
|
arg.Tags,
|
|
|
|
)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const createSubscription = `-- name: CreateSubscription :exec
|
|
|
|
|
|
|
|
Insert Into subscriptions (ID, DiscordWebHookId, SourceId) Values ($1, $2, $3)
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateSubscriptionParams struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Discordwebhookid uuid.UUID
|
|
|
|
Sourceid uuid.UUID
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subscriptions
|
|
|
|
func (q *Queries) CreateSubscription(ctx context.Context, arg CreateSubscriptionParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createSubscription, arg.ID, arg.Discordwebhookid, arg.Sourceid)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const deleteDiscordQueueItem = `-- name: DeleteDiscordQueueItem :exec
|
|
|
|
Delete From DiscordQueue Where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DeleteDiscordQueueItem(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, deleteDiscordQueueItem, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const deleteDiscordWebHooks = `-- name: DeleteDiscordWebHooks :exec
|
|
|
|
Delete From discordwebhooks Where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DeleteDiscordWebHooks(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, deleteDiscordWebHooks, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const deleteIcon = `-- name: DeleteIcon :exec
|
|
|
|
Delete From Icons where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DeleteIcon(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, deleteIcon, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const deleteSetting = `-- name: DeleteSetting :exec
|
|
|
|
Delete From settings Where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DeleteSetting(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, deleteSetting, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const deleteSource = `-- name: DeleteSource :exec
|
2022-12-07 22:48:31 -08:00
|
|
|
UPDATE Sources Set Disabled = TRUE where id = $1
|
2022-06-08 21:17:08 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DeleteSource(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, deleteSource, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const deleteSubscription = `-- name: DeleteSubscription :exec
|
2022-07-12 15:28:31 -07:00
|
|
|
Delete From subscriptions Where id = $1
|
2022-06-19 22:02:44 -07:00
|
|
|
`
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
func (q *Queries) DeleteSubscription(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, deleteSubscription, id)
|
2022-06-19 22:02:44 -07:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-08-21 20:02:45 -07:00
|
|
|
const disableDiscordWebHook = `-- name: DisableDiscordWebHook :exec
|
|
|
|
Update discordwebhooks Set Enabled = FALSE where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DisableDiscordWebHook(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, disableDiscordWebHook, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const disableSource = `-- name: DisableSource :exec
|
|
|
|
Update Sources Set Enabled = FALSE where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) DisableSource(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, disableSource, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-08-21 20:02:45 -07:00
|
|
|
const enableDiscordWebHook = `-- name: EnableDiscordWebHook :exec
|
|
|
|
Update discordwebhooks Set Enabled = TRUE where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) EnableDiscordWebHook(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, enableDiscordWebHook, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const enableSource = `-- name: EnableSource :exec
|
|
|
|
Update Sources Set Enabled = TRUE where ID = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) EnableSource(ctx context.Context, id uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, enableSource, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const getArticleByID = `-- name: GetArticleByID :one
|
|
|
|
Select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage from Articles
|
|
|
|
WHERE ID = $1 LIMIT 1
|
|
|
|
`
|
|
|
|
|
|
|
|
// Articles
|
|
|
|
func (q *Queries) GetArticleByID(ctx context.Context, id uuid.UUID) (Article, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getArticleByID, id)
|
|
|
|
var i Article
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getArticleByUrl = `-- name: GetArticleByUrl :one
|
|
|
|
Select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage from Articles
|
|
|
|
Where Url = $1 LIMIT 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetArticleByUrl(ctx context.Context, url string) (Article, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getArticleByUrl, url)
|
|
|
|
var i Article
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const getArticlesBySource = `-- name: GetArticlesBySource :many
|
2022-12-07 22:48:31 -08:00
|
|
|
select articles.id, sourceid, articles.tags, title, articles.url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage, sources.id, site, name, source, type, value, enabled, sources.url, sources.tags, deleted from articles
|
2022-06-19 22:02:44 -07:00
|
|
|
INNER join sources on articles.sourceid=Sources.ID
|
|
|
|
where site = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
type GetArticlesBySourceRow struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Sourceid uuid.UUID
|
|
|
|
Tags string
|
|
|
|
Title string
|
|
|
|
Url string
|
|
|
|
Pubdate time.Time
|
|
|
|
Video sql.NullString
|
|
|
|
Videoheight int32
|
|
|
|
Videowidth int32
|
|
|
|
Thumbnail string
|
|
|
|
Description string
|
|
|
|
Authorname sql.NullString
|
|
|
|
Authorimage sql.NullString
|
|
|
|
ID_2 uuid.UUID
|
|
|
|
Site string
|
|
|
|
Name string
|
|
|
|
Source string
|
|
|
|
Type string
|
|
|
|
Value sql.NullString
|
|
|
|
Enabled bool
|
|
|
|
Url_2 string
|
|
|
|
Tags_2 string
|
2022-12-07 22:48:31 -08:00
|
|
|
Deleted sql.NullBool
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetArticlesBySource(ctx context.Context, site string) ([]GetArticlesBySourceRow, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, getArticlesBySource, site)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []GetArticlesBySourceRow
|
|
|
|
for rows.Next() {
|
|
|
|
var i GetArticlesBySourceRow
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
&i.ID_2,
|
|
|
|
&i.Site,
|
|
|
|
&i.Name,
|
|
|
|
&i.Source,
|
|
|
|
&i.Type,
|
|
|
|
&i.Value,
|
|
|
|
&i.Enabled,
|
|
|
|
&i.Url_2,
|
|
|
|
&i.Tags_2,
|
2022-12-07 22:48:31 -08:00
|
|
|
&i.Deleted,
|
2022-06-19 22:02:44 -07:00
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const getArticlesBySourceName = `-- name: GetArticlesBySourceName :many
|
|
|
|
select
|
|
|
|
articles.ID, articles.SourceId, articles.Tags, articles.Title, articles.Url, articles.PubDate, articles.Video, articles.VideoHeight, articles.VideoWidth, articles.Thumbnail, articles.Description, articles.AuthorName, articles.AuthorImage, sources.source, sources.name
|
|
|
|
From articles
|
|
|
|
Left Join sources
|
|
|
|
On articles.sourceid = sources.id
|
|
|
|
Where name = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
type GetArticlesBySourceNameRow struct {
|
|
|
|
ID uuid.UUID
|
|
|
|
Sourceid uuid.UUID
|
|
|
|
Tags string
|
|
|
|
Title string
|
|
|
|
Url string
|
|
|
|
Pubdate time.Time
|
|
|
|
Video sql.NullString
|
|
|
|
Videoheight int32
|
|
|
|
Videowidth int32
|
|
|
|
Thumbnail string
|
|
|
|
Description string
|
|
|
|
Authorname sql.NullString
|
|
|
|
Authorimage sql.NullString
|
|
|
|
Source sql.NullString
|
|
|
|
Name sql.NullString
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetArticlesBySourceName(ctx context.Context, name string) ([]GetArticlesBySourceNameRow, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, getArticlesBySourceName, name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []GetArticlesBySourceNameRow
|
|
|
|
for rows.Next() {
|
|
|
|
var i GetArticlesBySourceNameRow
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
&i.Source,
|
|
|
|
&i.Name,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const getDiscordQueueByID = `-- name: GetDiscordQueueByID :one
|
|
|
|
Select id, articleid from DiscordQueue
|
|
|
|
Where ID = $1 LIMIT 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetDiscordQueueByID(ctx context.Context, id uuid.UUID) (Discordqueue, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getDiscordQueueByID, id)
|
|
|
|
var i Discordqueue
|
|
|
|
err := row.Scan(&i.ID, &i.Articleid)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
const getDiscordWebHookByUrl = `-- name: GetDiscordWebHookByUrl :one
|
|
|
|
Select id, url, server, channel, enabled From DiscordWebHooks Where url = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetDiscordWebHookByUrl(ctx context.Context, url string) (Discordwebhook, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getDiscordWebHookByUrl, url)
|
|
|
|
var i Discordwebhook
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Url,
|
|
|
|
&i.Server,
|
|
|
|
&i.Channel,
|
|
|
|
&i.Enabled,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const getDiscordWebHooksByID = `-- name: GetDiscordWebHooksByID :one
|
2022-06-19 22:02:44 -07:00
|
|
|
Select id, url, server, channel, enabled from DiscordWebHooks
|
2022-06-08 21:17:08 -07:00
|
|
|
Where ID = $1 LIMIT 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetDiscordWebHooksByID(ctx context.Context, id uuid.UUID) (Discordwebhook, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getDiscordWebHooksByID, id)
|
|
|
|
var i Discordwebhook
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Url,
|
|
|
|
&i.Server,
|
|
|
|
&i.Channel,
|
|
|
|
&i.Enabled,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-11-30 21:43:53 -08:00
|
|
|
const getDiscordWebHooksByServerAndChannel = `-- name: GetDiscordWebHooksByServerAndChannel :many
|
|
|
|
SELECT id, url, server, channel, enabled FROM DiscordWebHooks
|
|
|
|
WHERE Server = $1 and Channel = $2
|
|
|
|
`
|
|
|
|
|
|
|
|
type GetDiscordWebHooksByServerAndChannelParams struct {
|
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetDiscordWebHooksByServerAndChannel(ctx context.Context, arg GetDiscordWebHooksByServerAndChannelParams) ([]Discordwebhook, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, getDiscordWebHooksByServerAndChannel, arg.Server, arg.Channel)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Discordwebhook
|
|
|
|
for rows.Next() {
|
|
|
|
var i Discordwebhook
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Url,
|
|
|
|
&i.Server,
|
|
|
|
&i.Channel,
|
|
|
|
&i.Enabled,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const getIconByID = `-- name: GetIconByID :one
|
|
|
|
Select id, filename, site FROM Icons
|
|
|
|
Where ID = $1 Limit 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetIconByID(ctx context.Context, id uuid.UUID) (Icon, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getIconByID, id)
|
|
|
|
var i Icon
|
|
|
|
err := row.Scan(&i.ID, &i.Filename, &i.Site)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getIconBySite = `-- name: GetIconBySite :one
|
|
|
|
Select id, filename, site FROM Icons
|
|
|
|
Where Site = $1 Limit 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetIconBySite(ctx context.Context, site string) (Icon, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getIconBySite, site)
|
|
|
|
var i Icon
|
|
|
|
err := row.Scan(&i.ID, &i.Filename, &i.Site)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getSettingByID = `-- name: GetSettingByID :one
|
|
|
|
Select id, key, value, options From settings
|
|
|
|
Where ID = $1 Limit 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSettingByID(ctx context.Context, id uuid.UUID) (Setting, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getSettingByID, id)
|
|
|
|
var i Setting
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Key,
|
|
|
|
&i.Value,
|
|
|
|
&i.Options,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getSettingByKey = `-- name: GetSettingByKey :one
|
|
|
|
Select id, key, value, options From settings Where
|
|
|
|
Key = $1 Limit 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSettingByKey(ctx context.Context, key string) (Setting, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getSettingByKey, key)
|
|
|
|
var i Setting
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Key,
|
|
|
|
&i.Value,
|
|
|
|
&i.Options,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getSettingByValue = `-- name: GetSettingByValue :one
|
|
|
|
Select id, key, value, options From settings Where
|
|
|
|
Value = $1 Limit 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSettingByValue(ctx context.Context, value string) (Setting, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getSettingByValue, value)
|
|
|
|
var i Setting
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Key,
|
|
|
|
&i.Value,
|
|
|
|
&i.Options,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getSourceByID = `-- name: GetSourceByID :one
|
2022-12-07 22:48:31 -08:00
|
|
|
Select id, site, name, source, type, value, enabled, url, tags, deleted From Sources where ID = $1 Limit 1
|
2022-06-08 21:17:08 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSourceByID(ctx context.Context, id uuid.UUID) (Source, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getSourceByID, id)
|
|
|
|
var i Source
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Site,
|
|
|
|
&i.Name,
|
|
|
|
&i.Source,
|
|
|
|
&i.Type,
|
|
|
|
&i.Value,
|
|
|
|
&i.Enabled,
|
|
|
|
&i.Url,
|
|
|
|
&i.Tags,
|
2022-12-07 22:48:31 -08:00
|
|
|
&i.Deleted,
|
2022-06-08 21:17:08 -07:00
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
const getSourceByName = `-- name: GetSourceByName :one
|
2022-12-07 22:48:31 -08:00
|
|
|
Select id, site, name, source, type, value, enabled, url, tags, deleted from Sources where name = $1 Limit 1
|
2022-07-12 15:28:31 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSourceByName(ctx context.Context, name string) (Source, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getSourceByName, name)
|
|
|
|
var i Source
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Site,
|
|
|
|
&i.Name,
|
|
|
|
&i.Source,
|
|
|
|
&i.Type,
|
|
|
|
&i.Value,
|
|
|
|
&i.Enabled,
|
|
|
|
&i.Url,
|
|
|
|
&i.Tags,
|
2022-12-07 22:48:31 -08:00
|
|
|
&i.Deleted,
|
2022-07-12 15:28:31 -07:00
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-11-30 21:43:53 -08:00
|
|
|
const getSourceByNameAndSource = `-- name: GetSourceByNameAndSource :one
|
2022-12-07 22:48:31 -08:00
|
|
|
Select id, site, name, source, type, value, enabled, url, tags, deleted from Sources WHERE name = $1 and source = $2
|
2022-11-30 21:43:53 -08:00
|
|
|
`
|
|
|
|
|
|
|
|
type GetSourceByNameAndSourceParams struct {
|
|
|
|
Name string
|
|
|
|
Source string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetSourceByNameAndSource(ctx context.Context, arg GetSourceByNameAndSourceParams) (Source, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getSourceByNameAndSource, arg.Name, arg.Source)
|
|
|
|
var i Source
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Site,
|
|
|
|
&i.Name,
|
|
|
|
&i.Source,
|
|
|
|
&i.Type,
|
|
|
|
&i.Value,
|
|
|
|
&i.Enabled,
|
|
|
|
&i.Url,
|
|
|
|
&i.Tags,
|
2022-12-07 22:48:31 -08:00
|
|
|
&i.Deleted,
|
2022-11-30 21:43:53 -08:00
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const getSubscriptionsByDiscordWebHookId = `-- name: GetSubscriptionsByDiscordWebHookId :many
|
|
|
|
Select id, discordwebhookid, sourceid from subscriptions Where discordwebhookid = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSubscriptionsByDiscordWebHookId(ctx context.Context, discordwebhookid uuid.UUID) ([]Subscription, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, getSubscriptionsByDiscordWebHookId, discordwebhookid)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Subscription
|
|
|
|
for rows.Next() {
|
|
|
|
var i Subscription
|
|
|
|
if err := rows.Scan(&i.ID, &i.Discordwebhookid, &i.Sourceid); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const getSubscriptionsBySourceID = `-- name: GetSubscriptionsBySourceID :many
|
|
|
|
Select id, discordwebhookid, sourceid From subscriptions Where sourceid = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetSubscriptionsBySourceID(ctx context.Context, sourceid uuid.UUID) ([]Subscription, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, getSubscriptionsBySourceID, sourceid)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Subscription
|
|
|
|
for rows.Next() {
|
|
|
|
var i Subscription
|
|
|
|
if err := rows.Scan(&i.ID, &i.Discordwebhookid, &i.Sourceid); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const listArticles = `-- name: ListArticles :many
|
2023-02-04 20:10:55 -08:00
|
|
|
Select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage From articles
|
|
|
|
Order By PubDate DESC
|
|
|
|
offset $2
|
|
|
|
fetch next $1 rows only
|
2022-06-19 22:02:44 -07:00
|
|
|
`
|
|
|
|
|
2023-02-04 20:10:55 -08:00
|
|
|
type ListArticlesParams struct {
|
|
|
|
Limit int32
|
|
|
|
Offset int32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ListArticles(ctx context.Context, arg ListArticlesParams) ([]Article, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listArticles, arg.Limit, arg.Offset)
|
2022-06-19 22:02:44 -07:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Article
|
|
|
|
for rows.Next() {
|
|
|
|
var i Article
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
const listArticlesByDate = `-- name: ListArticlesByDate :many
|
2023-02-04 20:10:55 -08:00
|
|
|
Select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage From articles
|
|
|
|
ORDER BY pubdate desc
|
|
|
|
Limit $1
|
2022-07-12 15:28:31 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListArticlesByDate(ctx context.Context, limit int32) ([]Article, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listArticlesByDate, limit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Article
|
|
|
|
for rows.Next() {
|
|
|
|
var i Article
|
2023-01-31 08:19:23 -08:00
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const listArticlesByPage = `-- name: ListArticlesByPage :many
|
|
|
|
select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage from articles
|
|
|
|
order by pubdate desc
|
|
|
|
offset $2
|
|
|
|
fetch next $1 rows only
|
|
|
|
`
|
|
|
|
|
|
|
|
type ListArticlesByPageParams struct {
|
|
|
|
Limit int32
|
|
|
|
Offset int32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ListArticlesByPage(ctx context.Context, arg ListArticlesByPageParams) ([]Article, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listArticlesByPage, arg.Limit, arg.Offset)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Article
|
|
|
|
for rows.Next() {
|
|
|
|
var i Article
|
2022-07-12 15:28:31 -07:00
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2023-02-04 20:10:55 -08:00
|
|
|
const listArticlesBySourceId = `-- name: ListArticlesBySourceId :many
|
|
|
|
Select id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage From articles
|
|
|
|
Where sourceid = $1
|
|
|
|
Limit 50
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListArticlesBySourceId(ctx context.Context, sourceid uuid.UUID) ([]Article, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listArticlesBySourceId, sourceid)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Article
|
|
|
|
for rows.Next() {
|
|
|
|
var i Article
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-30 14:54:58 -07:00
|
|
|
const listDiscordQueueItems = `-- name: ListDiscordQueueItems :many
|
|
|
|
Select id, articleid from DiscordQueue LIMIT $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListDiscordQueueItems(ctx context.Context, limit int32) ([]Discordqueue, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listDiscordQueueItems, limit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Discordqueue
|
|
|
|
for rows.Next() {
|
|
|
|
var i Discordqueue
|
|
|
|
if err := rows.Scan(&i.ID, &i.Articleid); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const listDiscordWebHooksByServer = `-- name: ListDiscordWebHooksByServer :many
|
2022-06-19 22:02:44 -07:00
|
|
|
Select id, url, server, channel, enabled From DiscordWebHooks
|
2022-06-08 21:17:08 -07:00
|
|
|
Where Server = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListDiscordWebHooksByServer(ctx context.Context, server string) ([]Discordwebhook, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listDiscordWebHooksByServer, server)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Discordwebhook
|
|
|
|
for rows.Next() {
|
|
|
|
var i Discordwebhook
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Url,
|
|
|
|
&i.Server,
|
|
|
|
&i.Channel,
|
|
|
|
&i.Enabled,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const listDiscordWebhooks = `-- name: ListDiscordWebhooks :many
|
|
|
|
Select id, url, server, channel, enabled From discordwebhooks LIMIT $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListDiscordWebhooks(ctx context.Context, limit int32) ([]Discordwebhook, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listDiscordWebhooks, limit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Discordwebhook
|
|
|
|
for rows.Next() {
|
|
|
|
var i Discordwebhook
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Url,
|
|
|
|
&i.Server,
|
|
|
|
&i.Channel,
|
|
|
|
&i.Enabled,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2023-02-04 20:10:55 -08:00
|
|
|
const listNewArticlesBySourceId = `-- name: ListNewArticlesBySourceId :many
|
|
|
|
SELECT id, sourceid, tags, title, url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage FROM articles
|
|
|
|
Where sourceid = $1
|
|
|
|
ORDER BY pubdate desc
|
|
|
|
offset $3
|
|
|
|
fetch next $2 rows only
|
|
|
|
`
|
|
|
|
|
|
|
|
type ListNewArticlesBySourceIdParams struct {
|
|
|
|
Sourceid uuid.UUID
|
|
|
|
Limit int32
|
|
|
|
Offset int32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ListNewArticlesBySourceId(ctx context.Context, arg ListNewArticlesBySourceIdParams) ([]Article, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listNewArticlesBySourceId, arg.Sourceid, arg.Limit, arg.Offset)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Article
|
|
|
|
for rows.Next() {
|
|
|
|
var i Article
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Sourceid,
|
|
|
|
&i.Tags,
|
|
|
|
&i.Title,
|
|
|
|
&i.Url,
|
|
|
|
&i.Pubdate,
|
|
|
|
&i.Video,
|
|
|
|
&i.Videoheight,
|
|
|
|
&i.Videowidth,
|
|
|
|
&i.Thumbnail,
|
|
|
|
&i.Description,
|
|
|
|
&i.Authorname,
|
|
|
|
&i.Authorimage,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
const listSources = `-- name: ListSources :many
|
2022-12-07 22:48:31 -08:00
|
|
|
Select id, site, name, source, type, value, enabled, url, tags, deleted From Sources Limit $1
|
2022-06-19 22:02:44 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListSources(ctx context.Context, limit int32) ([]Source, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listSources, limit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Source
|
|
|
|
for rows.Next() {
|
|
|
|
var i Source
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Site,
|
|
|
|
&i.Name,
|
|
|
|
&i.Source,
|
|
|
|
&i.Type,
|
|
|
|
&i.Value,
|
|
|
|
&i.Enabled,
|
|
|
|
&i.Url,
|
|
|
|
&i.Tags,
|
2022-12-07 22:48:31 -08:00
|
|
|
&i.Deleted,
|
2022-06-19 22:02:44 -07:00
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
const listSourcesBySource = `-- name: ListSourcesBySource :many
|
2022-12-07 22:48:31 -08:00
|
|
|
Select id, site, name, source, type, value, enabled, url, tags, deleted From Sources where Source = $1
|
2022-06-08 21:17:08 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListSourcesBySource(ctx context.Context, source string) ([]Source, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listSourcesBySource, source)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Source
|
|
|
|
for rows.Next() {
|
|
|
|
var i Source
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Site,
|
|
|
|
&i.Name,
|
|
|
|
&i.Source,
|
|
|
|
&i.Type,
|
|
|
|
&i.Value,
|
|
|
|
&i.Enabled,
|
|
|
|
&i.Url,
|
|
|
|
&i.Tags,
|
2022-12-07 22:48:31 -08:00
|
|
|
&i.Deleted,
|
2022-06-08 21:17:08 -07:00
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
const listSubscriptions = `-- name: ListSubscriptions :many
|
|
|
|
Select id, discordwebhookid, sourceid From subscriptions Limit $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListSubscriptions(ctx context.Context, limit int32) ([]Subscription, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listSubscriptions, limit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Subscription
|
|
|
|
for rows.Next() {
|
|
|
|
var i Subscription
|
|
|
|
if err := rows.Scan(&i.ID, &i.Discordwebhookid, &i.Sourceid); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
2022-06-30 14:54:58 -07:00
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const listSubscriptionsBySourceId = `-- name: ListSubscriptionsBySourceId :many
|
|
|
|
Select id, discordwebhookid, sourceid From subscriptions where sourceid = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListSubscriptionsBySourceId(ctx context.Context, sourceid uuid.UUID) ([]Subscription, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, listSubscriptionsBySourceId, sourceid)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []Subscription
|
|
|
|
for rows.Next() {
|
|
|
|
var i Subscription
|
|
|
|
if err := rows.Scan(&i.ID, &i.Discordwebhookid, &i.Sourceid); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
const querySubscriptions = `-- name: QuerySubscriptions :one
|
|
|
|
Select id, discordwebhookid, sourceid From subscriptions Where discordwebhookid = $1 and sourceid = $2 Limit 1
|
2022-06-19 22:02:44 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
type QuerySubscriptionsParams struct {
|
|
|
|
Discordwebhookid uuid.UUID
|
|
|
|
Sourceid uuid.UUID
|
|
|
|
}
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
func (q *Queries) QuerySubscriptions(ctx context.Context, arg QuerySubscriptionsParams) (Subscription, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, querySubscriptions, arg.Discordwebhookid, arg.Sourceid)
|
|
|
|
var i Subscription
|
|
|
|
err := row.Scan(&i.ID, &i.Discordwebhookid, &i.Sourceid)
|
|
|
|
return i, err
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|