◊(Local Yarn Code "Check-in [624e5e2b]")

Overview
Comment:Fix series caching
Timelines: family | ancestors | descendants | both | deta-refactor
Files: files | file ages | folders
SHA3-256: 624e5e2b7eb85a38c3aef3debb5fe6644796b2afaf03db8ce38801ae82fbf283
User & Date: joel on 2020-01-13 00:52:40
Other Links: branch diff | manifest | tags
Context
2020-01-13
01:04
Fix cache db filename, index page Leaf check-in: e90a714a user: joel tags: deta-refactor
00:52
Fix series caching check-in: 624e5e2b user: joel tags: deta-refactor
00:37
Fix article+note listing query so date ordering actually works check-in: fc820f2f user: joel tags: deta-refactor
Changes

Modified crystalize.rkt from [e20fefa6] to [950c4fe1].

    13     13            pollen/setup)
    14     14   
    15     15   (require "dust.rkt" "snippets-html.rkt")
    16     16   
    17     17   (provide init-cache-db!
    18     18            cache-conn            ; The most eligible bachelor in Neo Yokyo
    19     19            parse-and-cache-article!
           20  +         cache-series!
    20     21            current-plain-title
    21     22            (schema-out cache:article)
    22     23            (schema-out cache:note)
    23     24            (schema-out cache:series)
    24     25            (schema-out cache:index-entry)
    25     26            articles
    26     27            articles+notes
................................................................................
    73     74      [listing-excerpt-html string/f]   ; Not used for now
    74     75      [listing-short-html   string/f])) ; Date and title only
    75     76   
    76     77   (define-schema cache:series #:table "series"
    77     78     ([id            id/f #:primary-key #:auto-increment]
    78     79      [page          symbol/f]
    79     80      [title         string/f]
    80         -   [published     date/f]
           81  +   [published     string/f]
    81     82      [noun-plural   string/f]
    82     83      [noun-singular string/f]))
    83     84   
    84     85   (define-schema cache:index-entry #:table "index_entries"
    85     86     ([id          id/f #:primary-key #:auto-increment]
    86     87      [entry       string/f]
    87     88      [subentry    string/f]
................................................................................
   389    390   ;; listing functions
   390    391   (define (unfence html-str)
   391    392     (regexp-replace* #px"<[\\/]{0,1}style>" html-str ""))
   392    393   
   393    394   ;; Save the current article to the `series` table of the SQLite cache
   394    395   ;; Should be called from a template for series pages
   395    396   (define (cache-series!)
          397  +  (define here-page (path->string (here-output-path)))
   396    398     (query-exec cache-conn
   397    399                 (delete (~> (from cache:series #:as s)
   398         -                          (where (= s.page ,(here-output-path))))))
   399         -  (insert-one! cache-conn
   400         -               (make-cache:series
   401         -                #:page (here-output-path)
   402         -                #:title (hash-ref (current-metas) 'title)
   403         -                #:published (hash-ref (current-metas) 'published "")
   404         -                #:noun-plural (hash-ref (current-metas) 'noun-plural "")
   405         -                #:noun-singular (hash-ref (current-metas) 'noun-singular ""))))
          400  +                          (where (= s.page ,here-page)))))
          401  +  (void
          402  +   (insert-one! cache-conn
          403  +                (make-cache:series
          404  +                 #:page (string->symbol here-page)
          405  +                 #:title (hash-ref (current-metas) 'title)
          406  +                 #:published (hash-ref (current-metas) 'published "")
          407  +                 #:noun-plural (hash-ref (current-metas) 'noun-plural "")
          408  +                 #:noun-singular (hash-ref (current-metas) 'noun-singular "")))))