summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-12 22:13:29 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-12 22:13:29 +0100
commit4f9ac385def826e898ff43063af29bca6a22f5ba (patch)
tree6ed67a7f1c12aebb6a59d812ecb4195d7e7d9193
parentc28b337c5033124c847662166ca4a3bf67943a4b (diff)
Properly calculate an article's publishing date.
-rw-r--r--mulkcms.lisp29
1 files changed, 21 insertions, 8 deletions
diff --git a/mulkcms.lisp b/mulkcms.lisp
index bcc2fe8..d835e2a 100644
--- a/mulkcms.lisp
+++ b/mulkcms.lisp
@@ -89,10 +89,11 @@
(defun paramify-article-data (revision-data comment-num &optional (comments nil commentary-p))
(destructuring-bind (rid article date title content author format status
- global-id &rest args)
+ global-id publishing-date &rest args)
revision-data
(declare (ignore args rid format author))
- (list :publishing-date date
+ (list :publishing-date publishing-date
+ :last-updated-date date
:title title
:body content
:article-id article
@@ -160,12 +161,15 @@
(defun find-all-revisions (characteristics &optional constraints)
(query
(format nil
- "SELECT (most_recent_revision(r)).*
- FROM (SELECT article_revisions_for_characteristics(a.id, ~A) AS revision
+ "SELECT (most_recent_revision(r)).*, (oldest_revision(r2)).date
+ FROM (SELECT article_revisions_for_characteristics(a.id, ~A)
+ AS revision
FROM articles a)
AS mr
JOIN article_revisions r ON r.id = mr.revision
- GROUP BY article
+ JOIN article_revisions r2 ON r.article = r2.article
+ WHERE r2.status IN ('published', 'syndicated')
+ GROUP BY r.article
HAVING ~A
ORDER BY (oldest_revision(r)).date DESC"
(make-characteristic-lists characteristics)
@@ -369,13 +373,22 @@
(defun find-article-params (article characteristics &optional commentary-p)
(let* ((revisions (find-article-revisions article characteristics))
(revision (first revisions))
- (revision-data (query "SELECT * FROM article_revisions WHERE id = $1"
+ (revision-data (query "SELECT *
+ FROM article_revisions
+ WHERE id = $1"
revision
- :row)))
+ :row))
+ (publishing-date (query "SELECT min(date)
+ FROM article_revisions
+ WHERE article = $1
+ AND status IN ('published', 'syndicated')"
+ article
+ :single)))
(cond ((null revision-data)
nil)
(t
- (paramify-article revision-data commentary-p)))))
+ (paramify-article (append revision-data (list publishing-date))
+ commentary-p)))))
(defun find-article-request-handler (path &optional action characteristics)
(with-db