@@ -7,31 +7,26 @@ db/base db/sqlite3 threading pollen/setup racket/match - (rename-in racket/list - (group-by group-list-by)) "dust.rkt" (except-in pollen/core select)) (provide init-cache-db! cache-conn ; The most eligible bachelor in Neo Yokyo (schema-out cache:article) (schema-out cache:note) - (schema-out cache:series) (schema-out cache:index-entry) (schema-out listing) delete-article! delete-notes! articles articles+notes listing-htmls fenced-listing - unfence - preheat-series! - series-grouped-list) + unfence) ;; Cache DB and Schemas (define DBFILE (build-path (current-project-root) "vitreous.sqlite")) (define cache-conn (make-parameter (sqlite3-connect #:database DBFILE #:mode 'create))) @@ -47,11 +42,11 @@ [author string/f] [conceal string/f] [series-page symbol/f] [noun-singular string/f] [note-count integer/f] - [content-html string/f] + [content-html string/f] [disposition string/f] [disp-html-anchor string/f] [listing-full-html string/f] ; full content but without notes [listing-excerpt-html string/f] ; Not used for now [listing-short-html string/f])) ; Date and title only @@ -71,18 +66,10 @@ [conceal string/f] [listing-full-html string/f] [listing-excerpt-html string/f] ; Not used for now [listing-short-html string/f])) ; Date and title only -(define-schema cache:series #:table "series" - ([id id/f #:primary-key #:auto-increment] - [page symbol/f] - [title string/f] - [published string/f] - [noun-plural string/f] - [noun-singular string/f])) - (define-schema cache:index-entry #:table "index_entries" ([id id/f #:primary-key #:auto-increment] [entry string/f] [subentry string/f] [page symbol/f] @@ -98,11 +85,10 @@ [html string/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) @@ -208,32 +194,5 @@ ;; Remove "" introduced by using ->html on docs containing output from ;; listing functions (define (unfence html-str) (regexp-replace* #px"<[\\/]{0,1}style>" html-str "")) - -;; -;; ~~~ Fetching series ~~~ -;; -(define (series-grouped-list) - (~> (for/list ([row (in-entities (cache-conn) - (order-by (from cache:series #:as s) - ([s.noun-plural #:asc])))]) 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)))