summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-22 16:12:46 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-22 16:12:46 +0100
commitdf928a8339af1148ec835d8f917385a73d57c767 (patch)
treecf7d7a39bac6c7b9781a9b11f98463b6e765ccff
parent0c55d369ae0884d4b127745bd19ee00d323897c8 (diff)
Calculate global article revision IDs by recursion over the child-parent relationship.
-rw-r--r--mulkcms.lisp29
1 files changed, 28 insertions, 1 deletions
diff --git a/mulkcms.lisp b/mulkcms.lisp
index 7c8bad5..1ca5359 100644
--- a/mulkcms.lisp
+++ b/mulkcms.lisp
@@ -561,6 +561,33 @@
FROM article_revisions
WHERE status = 'syndicated'"
:single))
+ (revisions-with-global-ids
+ (mapcar (lambda (x)
+ (let ((global-id
+ ;; FIXME: May want to specify a
+ ;; stopping condition in the
+ ;; recursive query.
+ (query
+ "WITH RECURSIVE q(rid, rglobal_id) AS (
+ SELECT id, global_id
+ FROM article_revisions
+ WHERE id = $1
+ UNION
+ SELECT id, global_id FROM q
+ JOIN article_revision_parenthood
+ ON rid = child
+ JOIN article_revisions
+ ON parent = id
+ )
+ SELECT rglobal_id
+ FROM q
+ WHERE rglobal_id IS NOT NULL"
+ (getf x :revision)
+ :single)))
+ ;; NOTE: This shadows the existing
+ ;; :GLOBAL-ID key in X.
+ (list* :global-id global-id x)))
+ revisions))
(template-params
(list :title *site-name*
:last-updated-date last-updated
@@ -569,7 +596,7 @@
:global-id *feed-global-id*
:authors authors
:feed-uri (link-to :view-atom-feed :absolute t)
- :articles revisions)))
+ :articles revisions-with-global-ids)))
(expand-template (template "article_feed")
template-params))))))))))