Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ jobs:

- name: Install Required OS packages
run: |
sudo apt update && \
sudo apt install -y xvfb unzip
sudo apt-get update && \
sudo apt-get install -y xvfb unzip

- name: Start up the supporting nginx services
run: |
Expand All @@ -148,7 +148,7 @@ jobs:
cd -

echo "Starting up docker compose services"
docker-compose -f "./supporting-data/docker-compose-gh-actions.yml" up --force-recreate -d
docker compose -f "./supporting-data/docker-compose-gh-actions.yml" up --force-recreate -d

# Give nginx a moment to have fully come up
sleep 1
Expand Down
63 changes: 25 additions & 38 deletions browser-extensions/common/js/lib/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,61 +708,48 @@ function generate_stat_most_runs_in_a_year(parkrun_results) {
}
}

// The number of parkruns that satisfy the equation 'p parkruns run at least p times'
// E.g. you have run 4 different parkruns at least 4 times.
function generate_stat_p_index(parkrun_results) {
var p_index = 0
const display_name = 'p-index'
var help = "The number of parkruns that satisfy the equation 'p parkruns run at least p times', e.g. if you have run 4 different parkruns at least 4 times each, your p-index is 4."
var event_attendance_tally = {}
var qualifying = []

parkrun_results.forEach(function (parkrun_event) {
parkrun_results.forEach((parkrun_event) => {
if (!(parkrun_event.name in event_attendance_tally)) {
event_attendance_tally[parkrun_event.name] = 0
}
event_attendance_tally[parkrun_event.name] += 1
})
// Sort events by number of runs descending
var event_attendance_sorted = Object.keys(event_attendance_tally).sort(function(a, b) {
return event_attendance_tally[b] - event_attendance_tally[a]
})
// Iterate through the events, and as long as the numbers of times we have
// run at the even is greater than the index value, increment the p-index
event_attendance_sorted.forEach(function(event_name, index) {

const event_attendance_sorted = Object.keys(event_attendance_tally).sort((a, b) => event_attendance_tally[b] - event_attendance_tally[a])

event_attendance_sorted.forEach((event_name, index) => {
if (event_attendance_tally[event_name] > index) {
p_index += 1
qualifying.push(`${event_name} (${event_attendance_tally[event_name]})`)
}
})
return {
"display_name": "p-index",
"help": "The number of parkruns that satisfy the equation 'p parkruns run at least p times', e.g. if you have run 4 different parkruns at least 4 times each, your p-index is 4.",
"value": p_index
}

var value = qualifying.length
help = `The number of parkrun events completed at least ${value} times. These are ${qualifying.join(", ")}.`
return { display_name, help, value }
}

// The number of volunteer roles which have been performed at least _v_ times.
// E.g. If you have volunteered in 4 different roles at least 4 times, your v-index
// is 4.
function generate_stat_v_index(volunteer_data) {

volunteer_roles = group_volunteer_data(volunteer_data)
function generate_stat_v_index(volunteer_data) {
const display_name = "v-index"
var help = "The number of volunteer roles which have been performed at least v times. E.g. If you have volunteered in 4 different roles at least 4 times, your v-index is 4."
var qualifying = []

var v_index = 0
var descending_tally = Object.keys(volunteer_roles).sort(function(a, b) {
return volunteer_roles[b] - volunteer_roles[a]
})
// Iterate through the roles, and as long as the number of times we have
// volunteered in the role is greater than the index value, increment the
// v-index
descending_tally.forEach(function(role_name, index) {
// console.log("index: " + index + " is " + role_name + " which has been completed " + volunteer_roles[role_name] + " times")
if (volunteer_roles[role_name] > index) {
v_index += 1
const descending_tally = Object.keys(volunteer_data).sort((a, b) => volunteer_data[b] - volunteer_data[a])
descending_tally.forEach((role_name, index) => {
if (volunteer_data[role_name] > index) {
qualifying.push(`${role_name} (${volunteer_data[role_name]})`)
}
})
return {
"display_name": "v-index",
"help": "The number of volunteer roles which have been performed at least v times. E.g. If you have volunteered in 4 different roles at least 4 times, your v-index is 4.",
"value": v_index
}

var value = qualifying.length
help = `The number of volunteer roles completed at least ${value} times. These are ${qualifying.join(", ")}.`
return { display_name, help, value }
}

// The maximum contiguous series of parkrun event numbers you have attended
Expand Down
3 changes: 2 additions & 1 deletion browser-extensions/common/js/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ function get_localised_default_value(param) {
}

function get_normalised_volunteer_role(role) {
mapped_role = null
var mapped_role = null
$.each(domains, function(domain, mappings) {
if ("text_volunteer_role_map" in mappings) {
if (role in mappings.text_volunteer_role_map) {
Expand All @@ -560,6 +560,7 @@ function get_normalised_volunteer_role(role) {
})
if (mapped_role === null) {
console.log("I18N: UNKNOWN VOLUNTEER ROLE: "+role)
mapped_role = role // allow for parkrun to add new roles
} else {
if (role != mapped_role) {
// console.log("I18N: mapped "+role+" to "+mapped_role)
Expand Down