File | Kind | Date | Size [bytes] |
---|---|---|---|
- {{ if eq .kind "crawl-logs" }} - {{ index (last 1 (split .path "/")) 0 }} - {{ else }} - {{ index (last 1 (split .path "/")) 0 }} - {{ end }} - [download] - | -{{ .kind }} | -{{ .timestamp }} | -{{ .filesize }} | -
{{ $c }} | - {{ end }} -
---|
{{ $c }} | - {{ end }} -
- You can download the underlying dataset for the above table from here. -
diff --git a/layouts/shortcodes/date-bar-chart.html b/layouts/shortcodes/date-bar-chart.html deleted file mode 100644 index 90f72fc..0000000 --- a/layouts/shortcodes/date-bar-chart.html +++ /dev/null @@ -1,22 +0,0 @@ -{{ $id := base64Encode (.Get "src") }} -- You can download the underlying dataset for the above graph from here. -
diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..37dba74 --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +from setuptools import setup, find_packages + +# This package contains a few helper functions +setup( + name='ukwa-reports', + version='0.1.0', + packages=find_packages(include=['ukwa_reports', 'ukwa_reports.*']), + install_requires=[ + 'jupyterlab', + 'jupyter-book', + 'altair', + 'jupytext', + ] +) diff --git a/static/css/main.css b/static/css/main.css deleted file mode 100644 index cafb2dc..0000000 --- a/static/css/main.css +++ /dev/null @@ -1,109 +0,0 @@ -html, body { - height: 100%; -} - -body { - padding-top: 55px; - display: flex; - text-align: center; - flex-direction: column; -} - -main { - margin: auto; - padding: 25px; - flex: 1 0 auto; -} - -main table { - text-align: left; -} - -main table th{ - border-bottom: 1px solid #333; -} -main table td { - padding: 1px 5px; -} -/*footer*/ - -.copyright { - margin: 15px 0; -} - -/*home page*/ - -.intro { - transform: translateY(22vh); -} - -.intro > h1 { - color: #212121; - font-size: 12vh; -} - -.intro > h2 { - color: #757575; - font-size: 3vmin; -} - -.intro > .profile { - width: 10vh; - height: 10vh; - border-radius: 50%; -} - -/*apply accent colour to links*/ - -a:link, a:visited { - color: var(--accent); -} - -a.icon:hover { - text-decoration: none; -} - -a:hover { - color: var(--accent) !important; -} - -/*paginator at bottom of list view*/ - -.pages { - padding: 15px 0; -} - -.pages-icon { - padding: 0 15px; -} - -/*list item for posts and projects*/ - -.item { - padding: 10px 0; -} - -.item-tag { - background-color: var(--accent); -} - -/*navigation bar icons*/ - -.navbar-icon { - font-size: 125%; - display: inline-block !important; -} - -/*coloured borders at top and bottom of the page*/ - -.navbar.navbar-default { - border-top: var(--border-width) solid var(--accent); -} - -footer { - border-bottom: var(--border-width) solid var(--accent); -} - -img { - max-width: 100%; -} diff --git a/themes/minimal b/themes/minimal deleted file mode 160000 index 7d92985..0000000 --- a/themes/minimal +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7d929851ffdd5a0752d8b1f05596cf7cbf907982 diff --git a/index.html b/ukwa_reports/__init__.py similarity index 100% rename from index.html rename to ukwa_reports/__init__.py diff --git a/ukwa_reports/solr_facet_helper.py b/ukwa_reports/solr_facet_helper.py new file mode 100644 index 0000000..4be44c7 --- /dev/null +++ b/ukwa_reports/solr_facet_helper.py @@ -0,0 +1,38 @@ +# +# This is a bit knarly but it helpfully flattens the Solr JSON API reponse +# (which is a kind of tree shape) into a flat table that Pandas can work with. +# +# See [Solr's JSON Facet API](https://lucene.apache.org/solr/guide/8_4/json-facet-api.html) +# + +def flatten_solr_buckets(solr_facets): + flat = [] + for key in solr_facets: + if isinstance(solr_facets[key], dict): + for vals in _flatten_facet_buckets(key, solr_facets): + flat.append(vals.copy()) + return flat + +def _flatten_facet_buckets(facet_name, bucket, values={}): + subfacets = [] + for bucket_name in bucket: + if isinstance(bucket[bucket_name],dict): + subfacets.append(bucket_name) + if len(subfacets) > 0: + for bucket_name in subfacets: + for sub_bucket in bucket[bucket_name]['buckets']: + values[bucket_name] = sub_bucket['val'] + for sub_values in _flatten_facet_buckets(bucket_name, sub_bucket, values.copy()): + yield sub_values + # Also deal with the special 'missing' bucket: + if 'missing' in bucket[bucket_name]: + values[bucket_name] = "missing" + for sub_values in _flatten_facet_buckets(bucket_name, bucket[bucket_name]['missing'], values.copy()): + yield sub_values + else: + for bucket_name in bucket: + if bucket_name != 'val': + values[bucket_name] = bucket[bucket_name] + yield values + +