2022-06-08 21:17:08 -07:00
|
|
|
/* Articles */
|
|
|
|
-- name: GetArticleByID :one
|
|
|
|
Select * from Articles
|
|
|
|
WHERE ID = $1 LIMIT 1;
|
|
|
|
|
|
|
|
-- name: GetArticleByUrl :one
|
|
|
|
Select * from Articles
|
|
|
|
Where Url = $1 LIMIT 1;
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
-- name: ListArticles :many
|
2023-02-04 20:15:10 -08:00
|
|
|
Select * From articles
|
|
|
|
Order By PubDate DESC
|
|
|
|
offset $2
|
|
|
|
fetch next $1 rows only;
|
2022-06-19 22:02:44 -07:00
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
-- name: ListArticlesByDate :many
|
2023-02-04 20:15:10 -08:00
|
|
|
Select * From articles
|
|
|
|
ORDER BY pubdate desc
|
|
|
|
Limit $1;
|
2022-07-12 15:28:31 -07:00
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
-- name: GetArticlesBySource :many
|
|
|
|
select * from articles
|
|
|
|
INNER join sources on articles.sourceid=Sources.ID
|
2022-11-06 19:07:44 -08:00
|
|
|
where site = $1;
|
|
|
|
|
2023-02-04 20:15:10 -08:00
|
|
|
-- name: ListNewArticlesBySourceId :many
|
2022-11-06 19:07:44 -08:00
|
|
|
SELECT * FROM articles
|
|
|
|
Where sourceid = $1
|
2023-02-04 20:15:10 -08:00
|
|
|
ORDER BY pubdate desc
|
|
|
|
offset $3
|
|
|
|
fetch next $2 rows only;
|
2022-06-19 22:02:44 -07:00
|
|
|
|
2023-02-04 20:15:10 -08:00
|
|
|
-- name: ListArticlesBySourceId :many
|
2022-06-19 22:02:44 -07:00
|
|
|
Select * From articles
|
2023-02-04 20:15:10 -08:00
|
|
|
Where sourceid = $1
|
|
|
|
Limit 50;
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
-- 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;
|
|
|
|
|
2023-01-31 08:19:23 -08:00
|
|
|
-- name: ListArticlesByPage :many
|
|
|
|
select * from articles
|
|
|
|
order by pubdate desc
|
|
|
|
offset $2
|
|
|
|
fetch next $1 rows only;
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
-- 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);
|
|
|
|
|
|
|
|
|
|
|
|
/* DiscordQueue */
|
|
|
|
-- name: CreateDiscordQueue :exec
|
|
|
|
Insert into DiscordQueue
|
|
|
|
(ID, ArticleId)
|
|
|
|
Values
|
|
|
|
($1, $2);
|
|
|
|
|
|
|
|
-- name: GetDiscordQueueByID :one
|
|
|
|
Select * from DiscordQueue
|
|
|
|
Where ID = $1 LIMIT 1;
|
|
|
|
|
|
|
|
-- name: DeleteDiscordQueueItem :exec
|
|
|
|
Delete From DiscordQueue Where ID = $1;
|
|
|
|
|
2022-06-30 14:54:58 -07:00
|
|
|
-- name: ListDiscordQueueItems :many
|
2022-06-08 21:17:08 -07:00
|
|
|
Select * from DiscordQueue LIMIT $1;
|
|
|
|
|
|
|
|
/* DiscordWebHooks */
|
|
|
|
-- 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
|
|
|
|
|
|
|
-- name: GetDiscordWebHooksByID :one
|
|
|
|
Select * from DiscordWebHooks
|
|
|
|
Where ID = $1 LIMIT 1;
|
|
|
|
|
|
|
|
-- name: ListDiscordWebHooksByServer :many
|
|
|
|
Select * From DiscordWebHooks
|
|
|
|
Where Server = $1;
|
|
|
|
|
2022-11-30 21:43:53 -08:00
|
|
|
-- name: GetDiscordWebHooksByServerAndChannel :many
|
|
|
|
SELECT * FROM DiscordWebHooks
|
|
|
|
WHERE Server = $1 and Channel = $2;
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
-- name: GetDiscordWebHookByUrl :one
|
|
|
|
Select * From DiscordWebHooks Where url = $1;
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
-- name: ListDiscordWebhooks :many
|
|
|
|
Select * From discordwebhooks LIMIT $1;
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
-- name: DeleteDiscordWebHooks :exec
|
|
|
|
Delete From discordwebhooks Where ID = $1;
|
|
|
|
|
2022-08-21 20:02:45 -07:00
|
|
|
-- name: DisableDiscordWebHook :exec
|
|
|
|
Update discordwebhooks Set Enabled = FALSE where ID = $1;
|
|
|
|
|
|
|
|
-- name: EnableDiscordWebHook :exec
|
|
|
|
Update discordwebhooks Set Enabled = TRUE where ID = $1;
|
2022-06-08 21:17:08 -07:00
|
|
|
|
|
|
|
/* Icons */
|
|
|
|
|
|
|
|
-- name: CreateIcon :exec
|
|
|
|
INSERT INTO Icons
|
|
|
|
(ID, FileName, Site)
|
|
|
|
VALUES
|
|
|
|
($1,$2,$3);
|
|
|
|
|
|
|
|
-- name: GetIconByID :one
|
|
|
|
Select * FROM Icons
|
|
|
|
Where ID = $1 Limit 1;
|
|
|
|
|
|
|
|
-- name: GetIconBySite :one
|
|
|
|
Select * FROM Icons
|
|
|
|
Where Site = $1 Limit 1;
|
|
|
|
|
|
|
|
-- name: DeleteIcon :exec
|
|
|
|
Delete From Icons where ID = $1;
|
|
|
|
|
|
|
|
/* Settings */
|
|
|
|
|
|
|
|
-- name: CreateSettings :one
|
|
|
|
Insert Into settings
|
|
|
|
(ID, Key, Value, OPTIONS)
|
|
|
|
Values
|
|
|
|
($1,$2,$3,$4)
|
|
|
|
RETURNING *;
|
|
|
|
|
|
|
|
-- name: GetSettingByID :one
|
|
|
|
Select * From settings
|
|
|
|
Where ID = $1 Limit 1;
|
|
|
|
|
|
|
|
-- name: GetSettingByKey :one
|
|
|
|
Select * From settings Where
|
|
|
|
Key = $1 Limit 1;
|
|
|
|
|
|
|
|
-- name: GetSettingByValue :one
|
|
|
|
Select * From settings Where
|
|
|
|
Value = $1 Limit 1;
|
|
|
|
|
|
|
|
-- name: DeleteSetting :exec
|
|
|
|
Delete From settings Where ID = $1;
|
|
|
|
|
|
|
|
/* Sources */
|
|
|
|
|
|
|
|
-- 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);
|
|
|
|
|
|
|
|
-- name: GetSourceByID :one
|
|
|
|
Select * From Sources where ID = $1 Limit 1;
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
-- name: GetSourceByName :one
|
|
|
|
Select * from Sources where name = $1 Limit 1;
|
|
|
|
|
2022-11-30 21:43:53 -08:00
|
|
|
-- name: GetSourceByNameAndSource :one
|
|
|
|
Select * from Sources WHERE name = $1 and source = $2;
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
-- name: ListSources :many
|
|
|
|
Select * From Sources Limit $1;
|
|
|
|
|
2022-06-08 21:17:08 -07:00
|
|
|
-- name: ListSourcesBySource :many
|
|
|
|
Select * From Sources where Source = $1;
|
|
|
|
|
|
|
|
-- name: DeleteSource :exec
|
2022-12-07 22:48:31 -08:00
|
|
|
UPDATE Sources Set Disabled = TRUE where id = $1;
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
-- name: DisableSource :exec
|
|
|
|
Update Sources Set Enabled = FALSE where ID = $1;
|
|
|
|
|
|
|
|
-- name: EnableSource :exec
|
|
|
|
Update Sources Set Enabled = TRUE where ID = $1;
|
|
|
|
|
|
|
|
|
|
|
|
/* Subscriptions */
|
|
|
|
|
|
|
|
-- name: CreateSubscription :exec
|
|
|
|
Insert Into subscriptions (ID, DiscordWebHookId, SourceId) Values ($1, $2, $3);
|
|
|
|
|
|
|
|
-- name: ListSubscriptions :many
|
|
|
|
Select * From subscriptions Limit $1;
|
|
|
|
|
2022-06-30 14:54:58 -07:00
|
|
|
-- name: ListSubscriptionsBySourceId :many
|
|
|
|
Select * From subscriptions where sourceid = $1;
|
|
|
|
|
2022-07-12 15:28:31 -07:00
|
|
|
-- name: QuerySubscriptions :one
|
|
|
|
Select * From subscriptions Where discordwebhookid = $1 and sourceid = $2 Limit 1;
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
-- name: GetSubscriptionsBySourceID :many
|
|
|
|
Select * From subscriptions Where sourceid = $1;
|
|
|
|
|
|
|
|
-- name: GetSubscriptionsByDiscordWebHookId :many
|
|
|
|
Select * from subscriptions Where discordwebhookid = $1;
|
|
|
|
|
|
|
|
-- name: DeleteSubscription :exec
|
2022-07-12 15:28:31 -07:00
|
|
|
Delete From subscriptions Where id = $1;
|