aboutsummaryrefslogtreecommitdiff
path: root/db/articles.rkt
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2024-03-28 02:48:32 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2024-03-28 02:48:50 +0900
commit727d7759e0a733c4575de5431160fbd090371728 (patch)
tree18826c18e097a36c86394c051c98b4776f73fdbe /db/articles.rkt
parentc114d5cedab38a2f6683eabb7c98e9943eecf8bf (diff)
Add source column to articles table.HEADmain
Diffstat (limited to 'db/articles.rkt')
-rw-r--r--db/articles.rkt23
1 files changed, 13 insertions, 10 deletions
diff --git a/db/articles.rkt b/db/articles.rkt
index b549dc9..091bd41 100644
--- a/db/articles.rkt
+++ b/db/articles.rkt
@@ -18,18 +18,18 @@
insert-article)
(define (fetch-article conn article-id)
- (match-let ([(vector timestamp hash title body)
- (query-row conn "SELECT timestamp, hash, title, body FROM diary.articles WHERE article_id = $1" article-id)])
- (make-article article-id (sql-datetime->srfi-date timestamp) hash title body)))
+ (match-let ([(vector timestamp hash source title body)
+ (query-row conn "SELECT timestamp, hash, source, title, body FROM diary.articles WHERE article_id = $1" article-id)])
+ (make-article article-id (sql-datetime->srfi-date timestamp) hash source title body)))
(define (fetch-latest-articles conn limit)
(define article-list
- (for/list ([(article-id timestamp hash title body)
+ (for/list ([(article-id timestamp hash source title body)
(in-query conn "
-SELECT article_id, timestamp, hash, title, body FROM diary.articles ORDER BY timestamp DESC LIMIT $1
+SELECT article_id, timestamp, hash, source, title, body FROM diary.articles ORDER BY timestamp DESC LIMIT $1
"
limit)])
- (make-article article-id (sql-datetime->srfi-date timestamp) hash title body)))
+ (make-article article-id (sql-datetime->srfi-date timestamp) hash source title body)))
(define article-tags
(for/hash ([(article-id l)
(in-query conn
@@ -99,12 +99,13 @@ RETURNING tag_id
(define (insert-article conn article)
(query-exec conn
"
-INSERT INTO diary.articles(article_id, timestamp, hash, title, body)
-VALUES($1, $2, $3, $4, $5)
+INSERT INTO diary.articles(article_id, timestamp, hash, source, title, body)
+VALUES($1, $2, $3, $4, $5, $6)
"
(article-id article)
(srfi-date->sql-timestamp-tz (article-timestamp article))
(article-hash article)
+ (article-source article)
(article-title article)
(article-body article)))
@@ -114,14 +115,16 @@ VALUES($1, $2, $3, $4, $5)
UPDATE diary.articles
SET timestamp = $2,
hash = $3,
- title = $4,
- body = $5
+ source = $4,
+ title = $5,
+ body = $6
WHERE article_id = $1
AND hash <> $3
"
(article-id article)
(srfi-date->sql-timestamp-tz (article-timestamp article))
(article-hash article)
+ (article-source article)
(article-title article)
(article-body article))))