Skip to content

First working version with stats + grouping #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 30, 2024
Merged
5 changes: 3 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{:deps {io.github.nextjournal/clerk {:git/sha "58c7b75c91585b9947f323b753e07cecdeec2a30"}}
{:deps {io.github.nextjournal/clerk {:git/sha "3acd9cffc533da1f1f67f6f8fb0158d320767fbc"}}
:aliases
{:dev {:paths ["notebooks"]
{:dev {:extra-paths ["notebooks"]
:extra-deps {com.github.seancorfield/next.jdbc {:mvn/version "1.3.925"}
com.github.seancorfield/honeysql {:mvn/version "2.6.1126"}
org.xerial/sqlite-jdbc {:mvn/version "3.34.0"}}}}}
45 changes: 39 additions & 6 deletions notebooks/table_stats.clj
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
(ns ^:nextjournal.clerk/no-cache table-stats
(:require [nextjournal.clerk :as clerk]
[nextjournal.clerk-table-stats :as table-stats]
[next.jdbc :as jdbc]))
[nextjournal.clerk-table-stats] ;; loaded for side effects
[next.jdbc :as jdbc]
[honey.sql :as sql]))

(comment
(clerk/serve! {}))
(clerk/serve! {})
(clerk/halt!)
(clerk/clear-cache!))

(def x (range 100))
;; - [x] Port grouping/nesting feature from ductile
;; - [x] Port some [stats](https://github.com/nextjournal/clerk/pull/156/files) stuff from Philippa in here?
;; - [x] compute-table-summary
;; - [ ] Think about how to query the remote data source for more information
;; - [x] honey.sql issue with clerk show!

;; ## SQL Queries
(def query-results
(let [_run-at #inst "2021-05-20T08:28:29.445-00:00"
ds (jdbc/get-datasource {:dbtype "sqlite" :dbname "chinook.db"})]
(with-open [conn (jdbc/get-connection ds)]
(clerk/table (jdbc/execute! conn ["SELECT AlbumId, Bytes, Name, TrackID, UnitPrice FROM tracks"])))))
(clerk/table (jdbc/execute! conn (sql/format {:select [:albums.title :Bytes :Name :TrackID
:UnitPrice]
:from :tracks
:join [:albums [:= :tracks.AlbumId :albums.AlbumId]]}))))))

(def nested-seq-of-map
[{:ars/id "1"
:compound/name "Krefeld"
:ductile/id #uuid "1174774f-17ec-442c-803f-2906015be68f"
:entry/datetime #inst "2023-09-28T06:33:01Z"
:entry/transport {:transport/mode :mode/truck
:transport/name "Kempers"}
:exit/transport {:transport/mode :mode/truck
:transport/name "Kempers"}}
{:ars/id "2"
:compound/name "Krefeld"
:ductile/id #uuid "774f1174-7ec1-2c44-3f80-15be68f29060"
:entry/transport {:transport/mode :mode/truck
:transport/name "Kempers"}
:exit/transport {:transport/mode :mode/truck}}])

(clerk/table {::clerk/render-opts {:group-headers true
:column-order [:compound/name
[:entry/transport [:transport/name :transport/mode]]
[:exit/transport [:transport/name :transport/mode]]
:entry/datetime]
:hide-columns [:ars/id :ductile/id]}} nested-seq-of-map)

Loading