diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-07-12 23:58:57 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-07-12 23:58:57 +0900 |
| commit | 756b66b31fd02215fc2d8a30ae263a3bf08a90a6 (patch) | |
| tree | 245cc37a1d81728260246ae5241eeb8225ec0ddc /backend/db/feeds.sql.go | |
| parent | fbe4bff7e8b6a5239c490601436fb3638dc8e13b (diff) | |
| download | feedaka-756b66b31fd02215fc2d8a30ae263a3bf08a90a6.tar.gz feedaka-756b66b31fd02215fc2d8a30ae263a3bf08a90a6.tar.zst feedaka-756b66b31fd02215fc2d8a30ae263a3bf08a90a6.zip | |
feat(backend,frontend): add feature to unsubscribe feed
Diffstat (limited to 'backend/db/feeds.sql.go')
| -rw-r--r-- | backend/db/feeds.sql.go | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/backend/db/feeds.sql.go b/backend/db/feeds.sql.go index 4db84af..29b26ca 100644 --- a/backend/db/feeds.sql.go +++ b/backend/db/feeds.sql.go @@ -12,7 +12,7 @@ import ( const createFeed = `-- name: CreateFeed :one INSERT INTO feeds (url, title, fetched_at) VALUES (?, ?, ?) -RETURNING id, url, title, fetched_at +RETURNING id, url, title, fetched_at, is_subscribed ` type CreateFeedParams struct { @@ -29,6 +29,7 @@ func (q *Queries) CreateFeed(ctx context.Context, arg CreateFeedParams) (Feed, e &i.Url, &i.Title, &i.FetchedAt, + &i.IsSubscribed, ) return i, err } @@ -44,7 +45,7 @@ func (q *Queries) DeleteFeed(ctx context.Context, id int64) error { } const getFeed = `-- name: GetFeed :one -SELECT id, url, title, fetched_at +SELECT id, url, title, fetched_at, is_subscribed FROM feeds WHERE id = ? ` @@ -57,12 +58,13 @@ func (q *Queries) GetFeed(ctx context.Context, id int64) (Feed, error) { &i.Url, &i.Title, &i.FetchedAt, + &i.IsSubscribed, ) return i, err } const getFeedByURL = `-- name: GetFeedByURL :one -SELECT id, url, title, fetched_at +SELECT id, url, title, fetched_at, is_subscribed FROM feeds WHERE url = ? ` @@ -75,13 +77,15 @@ func (q *Queries) GetFeedByURL(ctx context.Context, url string) (Feed, error) { &i.Url, &i.Title, &i.FetchedAt, + &i.IsSubscribed, ) return i, err } const getFeeds = `-- name: GetFeeds :many -SELECT id, url, title, fetched_at +SELECT id, url, title, fetched_at, is_subscribed FROM feeds +WHERE is_subscribed = 1 ORDER BY id ` @@ -99,6 +103,7 @@ func (q *Queries) GetFeeds(ctx context.Context) ([]Feed, error) { &i.Url, &i.Title, &i.FetchedAt, + &i.IsSubscribed, ); err != nil { return nil, err } @@ -116,6 +121,7 @@ func (q *Queries) GetFeeds(ctx context.Context) ([]Feed, error) { const getFeedsToFetch = `-- name: GetFeedsToFetch :many SELECT id, url, fetched_at FROM feeds +WHERE is_subscribed = 1 ` type GetFeedsToFetchRow struct { @@ -147,6 +153,17 @@ func (q *Queries) GetFeedsToFetch(ctx context.Context) ([]GetFeedsToFetchRow, er return items, nil } +const unsubscribeFeed = `-- name: UnsubscribeFeed :exec +UPDATE feeds +SET is_subscribed = 0 +WHERE id = ? +` + +func (q *Queries) UnsubscribeFeed(ctx context.Context, id int64) error { + _, err := q.db.ExecContext(ctx, unsubscribeFeed, id) + return err +} + const updateFeedMetadata = `-- name: UpdateFeedMetadata :exec UPDATE feeds SET title = ?, fetched_at = ? |
