@@ -28,10 +28,11 @@
listing-htmls
unfence
+ preheat-series!
series-grouped-list)
;; Cache DB and Schemas
(define DBFILE (build-path (current-project-root) "vitreous.sqlite"))
@@ -126,11 +127,11 @@
[(list series ...)
(where q (in a.series-page ,(map s->p series)))] ; WHERE series-page IN (item1 ...)
[(or (? string? series) (? symbol? series))
(where q (= a.series-page ,(s->p series)))] ; WHERE series-page = "item"
[#t
- (where q (= a.series-page ,(path->string (here-output-path))))]
+ (where q (like a.series-page ,(format "%~a" (here-output-path))))]
[_ q]))
;; (Private use) Convenience for the WHERE `conceal` NOT LIKE clause
(define (where-not-concealed q)
(define base-clause (where q (not (like a.conceal "%all%"))))
@@ -194,13 +195,12 @@
(define ( query-func #:series [s #t] #:limit [lim -1] #:order [ord 'desc])
`(style ,@(listing-htmls (query-func 'excerpt #:series s #:limit lim #:order ord))))
;; ^^^^^^^^
(define ( query-func #:series [s #t] #:limit [lim -1] #:order [ord 'desc])
- `(style ""
- ,@(listing-htmls (query-func 'short #:series s #:limit lim #:order ord))
- "
")) ;; ^^^^^^
+ `(style ,@(listing-htmls (query-func 'short #:series s #:limit lim #:order ord))))
+;; ^^^^^^
;; Remove "" introduced by using ->html on docs containing output from
;; listing functions
(define (unfence html-str)
(regexp-replace* #px"<[\\/]{0,1}style>" html-str ""))
@@ -209,5 +209,23 @@
;; ~~~ Fetching series ~~~
;;
(define (series-grouped-list)
(~> (for/list ([row (in-entities cache-conn (from cache:series #:as s))]) row)
(group-list-by cache:series-noun-plural _ string-ci=?)))
+
+;; Preloads the SQLite cache with info about each series.
+;; I may not actually need this but I’m leaving it for now.
+(define (preheat-series!)
+ (query-exec cache-conn
+ (~> (from cache:series #:as s)
+ (where 1)
+ delete))
+ (define series-rows
+ (for/list ([series-pagenode (in-list (cdr (series-pagetree)))])
+ (define series-metas (get-metas series-pagenode))
+ (make-cache:series
+ #:page series-pagenode
+ #:title (hash-ref series-metas 'title)
+ #:published (hash-ref series-metas 'published "")
+ #:noun-plural (hash-ref series-metas 'noun-plural "")
+ #:noun-singular (hash-ref series-metas 'noun-singular ""))))
+ (void (apply insert! cache-conn series-rows)))