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

Overview
Comment:Add and document save-cache-things!
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cbaca7d99370c230329eaf6fb9cdde8d70749a83f9ba7c1cc1937947855f73a4
User & Date: joel on 2020-03-20 03:24:18
Other Links: manifest | tags
Context
2020-03-20
03:25
Minor edits to code docs check-in: 1da389c4 user: joel tags: trunk
03:24
Add and document save-cache-things! check-in: cbaca7d9 user: joel tags: trunk
2020-03-15
21:42
Implement adding index entries via ‘keywords’ meta check-in: ecb3576a user: joel tags: trunk
Changes

Modified cache.rkt from [766a00d5] to [2a6f5661].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
         (schema-out cache:article)
         (schema-out cache:note)
         (schema-out cache:index-entry)
         (schema-out listing)
         delete-article!
         delete-notes!
         delete-index-entries!
         save-index-entries!
         articles
         articles+notes
         listing-htmls
         fenced-listing
         unfence)

;; Cache DB and Schemas
................................................................................

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

(define (save-index-entries! es)
  (void (apply insert! (cache-conn) es)))

;;
;;  ~~~ Fetching articles and notes ~~~
;;

;; (Private use) Conveniece function for the WHERE `series-page` clause







|







 







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
         (schema-out cache:article)
         (schema-out cache:note)
         (schema-out cache:index-entry)
         (schema-out listing)
         delete-article!
         delete-notes!
         delete-index-entries!
         save-cache-things!
         articles
         articles+notes
         listing-htmls
         fenced-listing
         unfence)

;; Cache DB and Schemas
................................................................................

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

(define (save-cache-things! es)
  (void (apply insert! (cache-conn) es)))

;;
;;  ~~~ Fetching articles and notes ~~~
;;

;; (Private use) Conveniece function for the WHERE `series-page` clause

Modified code-docs/cache.scrbl from [ed5e44d9] to [b6327b43].

136
137
138
139
140
141
142
143







144
145
146
147
148
149
150
The contents of the style tags are left intact.

Use this in templates with strings returned from @racket[->html] when called on docs that use the
@racket[fenced-listing] tag function.

}

@section{Deleting records}








@deftogether[(@defproc[(delete-article! [page stringish?]) void?]
              @defproc[(delete-notes!   [page stringish?]) void?])]{
              
Delete a particular article, or all notes for a particular article, respectively.

}







|
>
>
>
>
>
>
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
The contents of the style tags are left intact.

Use this in templates with strings returned from @racket[->html] when called on docs that use the
@racket[fenced-listing] tag function.

}

@section{Modifying the cache}

@defproc[(save-cache-things! 
          [things (listof (or/c cache:article? cache:note? cache:index-entry?))]) void?]{

Saves all the @racket[_thing]s to the cache database.

}

@deftogether[(@defproc[(delete-article! [page stringish?]) void?]
              @defproc[(delete-notes!   [page stringish?]) void?])]{
              
Delete a particular article, or all notes for a particular article, respectively.

}

Modified crystalize.rkt from [b135d898] to [f3846856].

258
259
260
261
262
263
264
265
266
(define (cache-index-entries! pagenode doc)
  (define-values (_ entry-txs) (splitf-txexpr doc index-entry-txpr?))
  (define all-entries
    (append (for/list ([etx (in-list entry-txs)]) (txexpr->index-entry etx pagenode))
            (current-metas-keyword-entries pagenode)))
  
  (delete-index-entries! pagenode)
  (save-index-entries! all-entries))
  







|

258
259
260
261
262
263
264
265
266
(define (cache-index-entries! pagenode doc)
  (define-values (_ entry-txs) (splitf-txexpr doc index-entry-txpr?))
  (define all-entries
    (append (for/list ([etx (in-list entry-txs)]) (txexpr->index-entry etx pagenode))
            (current-metas-keyword-entries pagenode)))
  
  (delete-index-entries! pagenode)
  (save-cache-things! all-entries))