◊(Local Yarn Code "Check-in [3ab1b16f]")

Overview
Comment:Prevent duplicate inserts in article cache
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3ab1b16f03d62930bcd07ce0ec04b41b94c52a541b5347083e2c44e5f8d60f31
User & Date: joel on 2020-01-19 21:29:00
Other Links: manifest | tags
Context
2020-01-19
21:31
Merge ignore-glob updates to trunk check-in: 233fdc64 user: joel tags: trunk
21:29
Prevent duplicate inserts in article cache check-in: 3ab1b16f user: joel tags: trunk
20:54
Makefile: turn on tidying; ‘all’→‘web’ check-in: c2036411 user: joel tags: trunk
Changes

Modified crystalize.rkt from [cb633ea2] to [08bca5d2].

96
97
98
99
100
101
102













103
104
105
106
107
108
109
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122







+
+
+
+
+
+
+
+
+
+
+
+
+







   [series-page symbol/f]))

(define (init-cache-db!)
  (create-table! cache-conn 'cache:article)
  (create-table! cache-conn 'cache:note)
  (create-table! cache-conn 'cache:series)
  (create-table! cache-conn 'cache:index-entry))

(define (delete-article! page)
  (query-exec cache-conn
              (~> (from cache:article #:as a)
                  (where (= a.page ,(format "~a" page)))
                  delete)))

(define (delete-notes! page)
  (query-exec cache-conn
              (~> (from cache:note #:as n)
                  (where (= n.page ,(format "~a" page)))
                  delete)))


;; Save an article and its notes (if any) to the database, and return the
;; rendered HTML of the complete article.
;;
(define (parse-and-cache-article! pagenode doc)
  (define-values (doc-no-title maybe-title)
    (splitf-txexpr doc (make-tag-predicate 'title)))
127
128
129
130
131
132
133

134
135
136
137
138
139
140
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154







+







                                               disp-note-id
                                               (length note-txprs))]
         [footer (html$-article-close footertext)]
         [listing-short (html$-article-listing-short pagenode pubdate title-html)]
         [notes-section-html (cache-notes! pagenode title-plain note-txprs)])
    (cache-index-entries! pagenode doc) ; note original doc is used here
    (current-plain-title title-plain)
    (delete-article! pagenode)
    (insert-one! cache-conn
                 (make-cache:article
                  #:page pagenode
                  #:title-plain title-plain
                  #:title-html-flow title-html
                  #:title-specified? title-specified?
                  #:published pubdate