Skip to content

Commit

Permalink
Add volunteering summary
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesdring committed Jan 22, 2025
1 parent cb8c264 commit 3b69662
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 40 deletions.
20 changes: 13 additions & 7 deletions pipelines/dvc.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ stages:
md5: e1f3e2145b08e5ba2e44d8ffce79b9c8
size: 5898
events@rise:
cmd: papermill --no-log-output events.ipynb output/events.ipynb -p id 'rise-event'
-p spektrix_event_ids '4801ANHPDLLRCQPPBDBQTRQJMPNKSLKPJ'
cmd: papermill --no-log-output events.ipynb output/events.ipynb -p spektrix_event_ids
'4801ANHPDLLRCQPPBDBQTRQJMPNKSLKPJ' -p venue_postcode 'BD1 1LA' -p rosterfy_event_ids
'25890' -p id 'rise-event'
deps:
- path: ../data/published/ticketing/
hash: md5
Expand All @@ -108,11 +109,16 @@ stages:
nfiles: 3
- path: events.ipynb
hash: md5
md5: 1eaafb389a0abf6bfca5f778077e968f
size: 1938
md5: 8d86e24fb541e30514402a1d4be4951f
size: 2438
outs:
- path: ../src/insights/rise-event/_data/tickets/
hash: md5
md5: 6df3e2b0104ce54577dda438ca829926.dir
size: 16650
nfiles: 2
md5: d2356aa987a4f2706582c17d23157945.dir
size: 16827
nfiles: 3
- path: ../src/insights/rise-event/_data/volunteers/
hash: md5
md5: 3f8561993c8f7c9b54a256d67d122a2e.dir
size: 79
nfiles: 1
8 changes: 7 additions & 1 deletion pipelines/dvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ stages:
# Set this in the `params.yaml` file
foreach: ${events}
do:
cmd: papermill --no-log-output events.ipynb output/events.ipynb -p id '${key}-event' -p spektrix_event_ids '${item.spektrix_event_ids}'
cmd: papermill --no-log-output events.ipynb output/events.ipynb
-p spektrix_event_ids '${item.spektrix_event_ids}'
-p venue_postcode '${item.venue_postcode}'
-p rosterfy_event_ids '${item.rosterfy_event_ids}'
-p id '${key}-event'
deps:
- events.ipynb
- ${ROOT}/data/published/ticketing/
outs:
- ${ROOT}/src/insights/${key}-event/_data/tickets/:
cache: false
- ${ROOT}/src/insights/${key}-event/_data/volunteers/:
cache: false
16 changes: 12 additions & 4 deletions pipelines/events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"source": [
"id: str = 'rise-event'\n",
"spektrix_event_ids: str = '4801ANHPDLLRCQPPBDBQTRQJMPNKSLKPJ'\n",
"venue_postcode: str = 'BD1 1LA'\n",
"rosterfy_event_ids: str = '25890'\n",
"\n",
"dates = ['2025-01-10 18:30:00', '2025-01-11 18:30:00']"
]
Expand All @@ -26,7 +28,7 @@
"\n",
"import petl as etl\n",
"\n",
"from utils.process.event import Tickets\n",
"from utils.process.event import Tickets, Volunteers\n",
"\n",
"from utils.paths import PUBLISHED, SITE"
]
Expand All @@ -39,7 +41,8 @@
"source": [
"OUTPUT_DIR = SITE / 'insights' / id / '_data'\n",
"TICKETS_DIR = OUTPUT_DIR / 'tickets'\n",
"TICKETS_DIR.mkdir(exist_ok=True, parents=True)"
"TICKETS_DIR.mkdir(exist_ok=True, parents=True)\n",
"VOLUNTEERS_DIR = OUTPUT_DIR / 'volunteers'"
]
},
{
Expand All @@ -66,10 +69,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": []
"source": [
"if rosterfy_event_ids:\n",
" VOLUNTEERS_DIR.mkdir(exist_ok=True, parents=True)\n",
" volunteers = Volunteers(str(rosterfy_event_ids).split())\n",
" volunteers.summarise().tocsv(VOLUNTEERS_DIR / 'summary.csv')"
]
}
],
"metadata": {
Expand Down
4 changes: 3 additions & 1 deletion pipelines/params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
events:
rise:
spektrix_event_ids: 4801ANHPDLLRCQPPBDBQTRQJMPNKSLKPJ
spektrix_event_ids: '4801ANHPDLLRCQPPBDBQTRQJMPNKSLKPJ'
venue_postcode: BD1 1LA
rosterfy_event_ids: '25890'
23 changes: 22 additions & 1 deletion pipelines/utils/process/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,25 @@ def summarise(self):
field="count_of_tickets"
)
.cache()
)
)


class Volunteers(object):
def __init__(self, ids: list[str]):
self.data = (
etl
.fromcsv(PUBLISHED / 'volunteers/shifts.csv').selectin('rosterfy_event_id', ids)
.convertnumbers()
)

def summarise(self):
config = {
'attended': ('attended', sum),
'hours': ('hours', sum),
}

agg = self.data.aggregate(key='date', aggregation=config)
return etl.cat(
agg,
agg.aggregate(key=None, aggregation=config).addfield('date', 'ALL')
)
10 changes: 4 additions & 6 deletions src/insights/rise-event/_components/BigNumber.vto
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
---
css: |
[data-comp=big-number] {
color: var(--block-fg) !important;
background: var(--block-bg);
padding: 1em;
display: flex;
display: flex !important;
flex-direction: column;
align-items: center;
& p {
margin-block: 0;
}
& .number {
font-size: 3em;
font-size: min(4em, var(--big-number-size, 20vw));
font-weight: bold;
}
}
---
<div data-comp="big-number" class="{{ classes || ""}}">
<p class="number">{{ number }}</p>
<div data-comp="big-number" class="block {{ classes || ""}}">
<p class="number">{{ number }}{{ if suffix }} {{ suffix }}{{ /if }}</p>
{{ content }}
</div>
26 changes: 26 additions & 0 deletions src/insights/rise-event/_components/event/Headlines.vto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<section class="grid">
{{ if tickets }}
{{ comp BigNumber {
number: tickets.summary.find(x => x.start == 'ALL').count_of_tickets.toLocaleString(),
suffix: 'tickets',
classes: 'c-pink',
} }}
<p>Total tickets sold</p>
{{ /comp }}
{{ /if }}

{{ if volunteers }}
{{ comp BigNumber {
number: volunteers.summary.find(x => x.date == 'ALL').hours.toLocaleString(),
suffix: 'volunteer hours',
classes: 'c-yellow',
} }}
<p>
Overall there were
{{ volunteers.summary.find(x => x.date == 'ALL').hours.toLocaleString() }}
hours of volunteering across
{{ volunteers.summary.find(x => x.date == 'ALL').attended.toLocaleString() }}
individual shifts.
</p>
{{ /comp }}
{{ /if }}
22 changes: 3 additions & 19 deletions src/insights/rise-event/_components/event/Tickets.vto
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@

<section>
<h2>Tickets</h2>

{{ comp BigNumber {
number: tickets.summary.find(x => x.start == 'ALL').count_of_tickets.toLocaleString(),
classes: 'c-pink',
} }}
<p>Total tickets sold</p>
{{ /comp }}

<h2>Geographic ticket allocation</h2>
<h3>Geographic ticket allocation</h3>
{{> const by_ward = tickets.by_geography
.filter(x => x.start == 'ALL' && x.geography_type == 'osward' && x.geography_code !== 'OTHER')
.map(w => ({
Expand Down Expand Up @@ -65,7 +57,7 @@

<div>
<p>
The maps to the show tickets sold across the wards of Bradford.
The maps show tickets sold across the wards of Bradford.
</p>
<p>
In addition to this visitors came from outside Bradford:
Expand Down Expand Up @@ -107,7 +99,7 @@ or the ticket holder's postcode was missing or otherwise invalid.
</p>
</section>

<h2>Ticket types</h2>
<h3>Ticket types</h3>

<section class="grid regular">
<div class="block">
Expand Down Expand Up @@ -171,13 +163,5 @@ or the ticket holder's postcode was missing or otherwise invalid.
</ul>
</div>
</section>
<hr>

{{#
<code><pre>
{{ tickets.summary |> JSON.stringify }}
{{ tickets.by_geography |> JSON.stringify }}
</pre></code>
#}}

</section>
Empty file.
4 changes: 4 additions & 0 deletions src/insights/rise-event/_data/volunteers/summary.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
date,attended,hours
2025-01-10,92,613.5
2025-01-11,91,500.5
ALL,183,1114.0
4 changes: 3 additions & 1 deletion src/insights/rise-event/index.vto
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ description: Event monitoring report for RISE, 10-11 January 2025
draft: true
---

{{ comp.event.Tickets({ tickets })}}
{{ comp.event.Headlines({ tickets, volunteers }) }}

{{ if tickets }}{{ comp.event.Tickets({ tickets }) }}{{ /if }}

0 comments on commit 3b69662

Please sign in to comment.