Skip to content

Commit

Permalink
fix: update repo for new challenge (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenakh97 authored Apr 25, 2024
1 parent 95049ee commit d9aba2c
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 27 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@nordicplayground/strava-challenge-2022",
"name": "@nordicplayground/TheNordicChallenge",
"version": "0.0.0-development",
"description": "A single-page application (SPA) developed using TypeScript to play a game of nRF Robot Wars.",
"type": "module",
Expand All @@ -12,12 +12,12 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/NordicPlayground/StravaChallenge2022.git"
"url": "git+https://github.com/NordicPlayground/TheNordicChallenge.git"
},
"bugs": {
"url": "https://github.com/NordicPlayground/StravaChallenge2022/issues"
"url": "https://github.com/NordicPlayground/TheNordicChallenge/issues"
},
"homepage": "https://github.com/NordicPlayground/StravaChallenge2022#readme",
"homepage": "https://github.com/NordicPlayground/TheNordicChallenge#readme",
"keywords": [
"nrf-asset-tracker",
"iot",
Expand Down
1 change: 1 addition & 0 deletions public/api_logo_pwrdBy_strava_stack_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 28 additions & 14 deletions src/app/pages/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,46 @@ export const About = () => {
<div className="card-header">About</div>
<div className="card-body">
<p>
Each week the kilometers for each club will be added up and then
divided by the size of the office/location headcount. Inactive users
will not count in the calculations.
Each week the points for each club will be added up and then divided
by the size of the office/location headcount. By doing it this way
we make sure every activity counts positively against the challenge,
no matter how short.
</p>
<p>
In general activities will give a 1 km = 1 point ratio in the
statistics, but we have some adjustments as described in this
section.
</p>
<p>
As biking/skiing is more efficient in km than running/walking, we
will be using a ratio for this, and for each 3km cycled = 1km
run/walk.{' '}
will be using a ratio for this, and for each 3km cycled = 1 points.{' '}
</p>
<p>
This ratio counts for the following activities: <b>Ride</b>,{' '}
<b>Virtual Bike</b>, <b>Roller Ski</b>,<b> Nordic Ski</b>,{' '}
<b>BackCountry Ski</b>, <b>Gravel Ride</b> and{' '}
<b>Mountain Bike Ride</b>.
</p>
For the same reason, 1km of <b>swimming</b> equals 4km of
running/walking.
For the same reason, 1km of <b>swimming</b> equals 4 points.
<p>
<b> E-Bike Ride </b> has a 5:1 km ratio.
<b> E-Bike Ride </b> has a 5 km = 1 points ratio.
</p>
<b> Snowboard </b>
and <b>Alpine Ski</b> is given 0km in the statistics.
<p>
All time spent doing activities counts towards the statistics, and
all activities not mentioned above will give a 1:1km ratio in the
statistics.
<b> Snowboard </b>
and <b>Alpine Ski</b> is given 0 distance but will give points as an{' '}
<b>activity without distance</b> as described below.
</p>
<p>
<b>Activities without distance</b>; like <b>Yoga</b>,{' '}
<b>WeightTraining</b> etc are given points based on time. The
following formula shows how this is done:
</p>
<p>
<b> Time [hours] * 5 points</b>
</p>
<p>
This means that 1 hour of activity without distance is equivalent to
5 points. 30 min of activity gives 2.5 points and so on.
</p>
</div>
</div>
Expand Down Expand Up @@ -60,7 +74,7 @@ export const About = () => {
<div className="card-body">
<dl>
<ul>
<li>The challenge starts April 17th and ends May 15th.</li>
<li>The challenge starts May 6th and ends June 2nd.</li>
<li>
You need a user account on Strava to participate{' '}
<a href="https://www.strava.com">www.strava.com</a>
Expand Down
6 changes: 5 additions & 1 deletion src/app/pages/Clubgoals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const ClubGoals = () => {

const fetchData = async () => {
const result = await fetch(
`https://l3svp5tprslh63jdazjgg6mdta0ocgkr.lambda-url.eu-central-1.on.aws/`,
`https://k66fzrj7leiarkgqtenq2udn3a0oznzh.lambda-url.us-east-2.on.aws/`,
)
setTimestreamData(await result.json())
setExp(
Expand Down Expand Up @@ -129,7 +129,11 @@ export const ClubGoals = () => {
}
}
const teams = Object.keys(distanceRecord)
console.log(teams)
console.log(timestreamData)

for (const team of teams) {
console.log(team)
distanceRecord[team].activeAthletes =
timestreamData.overall.teamInfo[team].memberCount
}
Expand Down
84 changes: 77 additions & 7 deletions src/app/pages/Strava.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const Strava = () => {

const fetchData = async () => {
const result = await fetch(
`https://l3svp5tprslh63jdazjgg6mdta0ocgkr.lambda-url.eu-central-1.on.aws/`,
`https://k66fzrj7leiarkgqtenq2udn3a0oznzh.lambda-url.us-east-2.on.aws/`,
)
setTimestreamData(await result.json())
setExp(
Expand Down Expand Up @@ -90,19 +90,89 @@ export const Strava = () => {
</Main>
)
}
let defaultWeekInfo: TeamInformation = [
{
teamName: 'Finland',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174164,
points: 0,
},

{
teamName: 'Poland',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174165,
points: 0,
},

{
teamName: 'Europe',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174166,
points: 0,
},

{
teamName: 'APAC',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174167,
points: 0,
},

{
teamName: 'USA',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174168,
points: 0,
},

{
teamName: 'Trondheim',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174140,
points: 0,
},

{
teamName: 'Omega',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174791,
points: 0,
},

{
teamName: 'Oslo',
minutesPerAthlete: 0,
distance: 0,
teamId: 1174162,
points: 0,
},
]
let currenWeektTeamInformation = []
for (const weeks of timestreamData.weeks) {
if (weeks.weekNumber === weekNumber) {
currenWeektTeamInformation.push(weeks.teamInformation)
} else {
currenWeektTeamInformation = []
currenWeektTeamInformation.push(weeks.teamInformation)
}
continue /*else {
console.log('else')
//currenWeektTeamInformation = []
currenWeektTeamInformation.push(weeks.teamInformation)
}*/
}
if (currenWeektTeamInformation.length === 0) {
currenWeektTeamInformation.push(defaultWeekInfo)
}
const weeklyHoursSorted = sortSummaryByHours(currenWeektTeamInformation[0])

const graphData = summaryDataToGraphData(timestreamData.weeks)

console.log('current', currenWeektTeamInformation)
for (const team of graphData.datasets) {
for (const teamName of currenWeektTeamInformation[0]) {
if (team.label === teamName.teamName) {
Expand All @@ -114,8 +184,8 @@ export const Strava = () => {
const tableData = (currenWeektTeamInformation[0] ?? []).sort(
(a: { points: number }, b: { points: number }) => b.points - a.points,
)
console.log(tableData)

console.log('tabledata', tableData)
console.log(weeklyHoursSorted)
return (
<Main>
<>
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/WeeklySummaries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const WeeklySummaries = () => {

const fetchData = async () => {
const result = await fetch(
`https://l3svp5tprslh63jdazjgg6mdta0ocgkr.lambda-url.eu-central-1.on.aws/`,
`https://k66fzrj7leiarkgqtenq2udn3a0oznzh.lambda-url.us-east-2.on.aws/`,
)
setTimestreamData(await result.json())
setExp(
Expand Down
7 changes: 7 additions & 0 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export const Navbar = () => {
</ul>
</div>
</div>
<img
src={'/api_logo_pwrdBy_strava_stack_white.svg'}
alt={'name'}
width="100"
height="34"
className="d-inline-block align-text-top me-1"
/>
</div>
</nav>
</header>
Expand Down

0 comments on commit d9aba2c

Please sign in to comment.