◊(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     96      [series-page symbol/f]))
    97     97   
    98     98   (define (init-cache-db!)
    99     99     (create-table! cache-conn 'cache:article)
   100    100     (create-table! cache-conn 'cache:note)
   101    101     (create-table! cache-conn 'cache:series)
   102    102     (create-table! cache-conn 'cache:index-entry))
          103  +
          104  +(define (delete-article! page)
          105  +  (query-exec cache-conn
          106  +              (~> (from cache:article #:as a)
          107  +                  (where (= a.page ,(format "~a" page)))
          108  +                  delete)))
          109  +
          110  +(define (delete-notes! page)
          111  +  (query-exec cache-conn
          112  +              (~> (from cache:note #:as n)
          113  +                  (where (= n.page ,(format "~a" page)))
          114  +                  delete)))
          115  +
   103    116   
   104    117   ;; Save an article and its notes (if any) to the database, and return the
   105    118   ;; rendered HTML of the complete article.
   106    119   ;;
   107    120   (define (parse-and-cache-article! pagenode doc)
   108    121     (define-values (doc-no-title maybe-title)
   109    122       (splitf-txexpr doc (make-tag-predicate 'title)))
................................................................................
   127    140                                                  disp-note-id
   128    141                                                  (length note-txprs))]
   129    142            [footer (html$-article-close footertext)]
   130    143            [listing-short (html$-article-listing-short pagenode pubdate title-html)]
   131    144            [notes-section-html (cache-notes! pagenode title-plain note-txprs)])
   132    145       (cache-index-entries! pagenode doc) ; note original doc is used here
   133    146       (current-plain-title title-plain)
          147  +    (delete-article! pagenode)
   134    148       (insert-one! cache-conn
   135    149                    (make-cache:article
   136    150                     #:page pagenode
   137    151                     #:title-plain title-plain
   138    152                     #:title-html-flow title-html
   139    153                     #:title-specified? title-specified?
   140    154                     #:published pubdate