Skip to content

Commit

Permalink
feat(evidence): add species page
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenwindflower committed Jun 23, 2024
1 parent e10ec93 commit 804a03e
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.11.x"
python-version: "3.12.x"
- name: Install Python dependencies
run: |
python3 -m pip install uv
Expand Down
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"sqltools.connections": [
{
"name": "dbtree",
"accessMode": "Read Only",
"previewLimit": 50,
"driver": "DuckDB",
"databaseFilePath": "/Users/winnie/dev/dbtree/dbtree.db"
}
],
"sqltools.useNodeRuntime": true
}
5 changes: 4 additions & 1 deletion models/marts/species.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ species as (

select
species_friendly_name,
species_scientific_name,
'https://wikipedia.org/wiki/'
|| replace(species_scientific_name, ' ', '_') as wikipedia_link,
count(*) as count_of_trees,

from trees

group by 1
group by 1, 2

)

Expand Down
3 changes: 3 additions & 0 deletions reports/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ order by count_of_trees desc
data={trees_planted_years}
value="year"
/>

<CalendarHeatmap
data={trees_planted_per_year}
date="planted_at_date"
Expand Down Expand Up @@ -94,13 +95,15 @@ In between <Value data={planted_at_date_range} column=start fmt='longdate' /> an
title="Planted between dates"
dates=planted_at_month
/>

<Dropdown
name="planted_at_species"
data={unique_species}
value="species_friendly_name"
title="Filter by species"
multiple=true
/>

<BarChart
data={trees_planted}
x="planted_at_month"
Expand Down
3 changes: 0 additions & 3 deletions reports/pages/map.md

This file was deleted.

42 changes: 42 additions & 0 deletions reports/pages/species.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Species
---

<script>
let myColors = [
"#D7E4C0",
"#C6DCBA",
"#BBC3A4",
"#B3A398",
"#638889"
]
</script>

This page lets you scope the data to a single species of tree. It's a bit of a work in progress, but I'm excited to see where it goes!

**NB:** This list is filtered to species with a scientific name in the data, to support the Wikipedia links.

<Dropdown
data={species}
name=species_select
title="Select a species"
defaultValue="Blue Oak"
value=species_friendly_name
/>

The <Value data={selected_species} column=species_friendly_name /> is an amazing tree!

<LinkButton url={selected_species[0].wikipedia_link}>
Read more on Wikipedia!
</LinkButton>

The Wikipedia links are inferred from the listed scientific name in the data, so they're not perfect and may take you to a non-existent page. Sorry! Hopefully I'll find a way around this soon.

```sql selected_species
select * from species where species_friendly_name = '${inputs.species_select.value}'
```

```sql species
select * from dbtree.species
where species_scientific_name is not null
```

0 comments on commit 804a03e

Please sign in to comment.