45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[published string/f]
[updated string/f]
[author string/f]
[conceal string/f]
[series-page symbol/f]
[noun-singular string/f]
[note-count integer/f]
[doc-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
(define-schema cache:note #:table "notes"
|
|
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[published string/f]
[updated string/f]
[author string/f]
[conceal string/f]
[series-page symbol/f]
[noun-singular string/f]
[note-count integer/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
(define-schema cache:note #:table "notes"
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
[entry string/f]
[subentry string/f]
[page symbol/f]
[html-anchor string/f]))
(define-schema listing
#:virtual
([html string/f]
[published date/f]
[series-page symbol/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))
|
|
>
>
|
>
|
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
[entry string/f]
[subentry string/f]
[page symbol/f]
[html-anchor string/f]))
(define-schema listing
#:virtual
([path string/f]
[title string/f]
[author string/f]
[published string/f]
[updated string/f]
[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))
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
;; Needed to "parameterize" column names
;; see https://github.com/Bogdanp/deta/issues/14#issuecomment-573344928
(require (prefix-in ast: deta/private/ast))
;; Builds a query to fetch articles
(define (articles type #:series [s #t] #:limit [lim -1] #:order [ord 'desc])
(define html-field (format "listing_~a_html" type))
(~> (from cache:article #:as a)
(select (fragment (ast:as (ast:qualified "a" html-field) "html"))
a.published
a.series-page
a.conceal)
(where-series s)
(where-not-concealed)
(limit ,lim)
(order-by ([a.published ,ord]))
(project-onto listing-schema)))
;; Builds a query that returns articles and notes intermingled chronologically
(define (articles+notes type #:series [s #t] #:limit [lim -1] #:order [ord 'desc])
(define html-field (format "listing_~a_html" type))
(~> (from (subquery
(~> (from cache:article #:as A)
(select (fragment (ast:as (ast:qualified "A" html-field) "html"))
A.published
A.series-page
A.conceal)
(union
(~> (from cache:note #:as N)
(select (fragment (ast:as (ast:qualified "N" html-field) "html"))
N.published
N.series-page
N.conceal)))))
#:as a)
(where-series s)
(where-not-concealed)
(limit ,lim)
(order-by ([a.published ,ord]))
(project-onto listing-schema)))
|
|
>
>
>
|
>
>
<
|
>
|
>
>
>
|
>
>
>
|
>
>
|
|
|
>
>
>
|
>
>
|
|
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
;; Needed to "parameterize" column names
;; see https://github.com/Bogdanp/deta/issues/14#issuecomment-573344928
(require (prefix-in ast: deta/private/ast))
;; Builds a query to fetch articles
(define (articles type #:series [s #t] #:limit [lim -1] #:order [ord 'desc])
(define html-field
(match type
['content "content_html"]
[_ (format "listing_~a_html" type)]))
(~> (from cache:article #:as a)
(select (as a.page path)
(as a.title-plain title)
a.author
a.published
a.updated
(fragment (ast:as (ast:qualified "a" html-field) "html")))
(where-series s)
(where-not-concealed)
(limit ,lim)
(order-by ([a.published ,ord]))
(project-onto listing-schema)))
;; Builds a query that returns articles and notes intermingled chronologically
(define (articles+notes type #:series [s #t] #:limit [lim -1] #:order [ord 'desc])
(define html-field
(match type
['content "content_html"]
[_ (format "listing_~a_html" type)]))
(~> (from (subquery
(~> (from cache:article #:as A)
(select
(as A.page path)
(as A.title-plain title)
A.author
A.published
A.updated
(fragment (ast:as (ast:qualified "A" html-field) "html"))
A.series-page
A.conceal)
(union
(~> (from cache:note #:as N)
(select
(as (array-concat N.page "#" N.html-anchor) path)
(as N.title-plain title)
N.author
N.published
(as "" updated)
(fragment (ast:as (ast:qualified "N" html-field) "html"))
N.series-page
N.conceal)))))
#:as a)
(where-series s)
(where-not-concealed)
(limit ,lim)
(order-by ([a.published ,ord]))
(project-onto listing-schema)))
|