-
Notifications
You must be signed in to change notification settings - Fork 1
[CL-103] Scores and Boards #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fffe25d
add timestamp
jeepies 7d8373b
add timestamp to history
jeepies 994dfe5
add timestamp values to seed data
jeepies 78f467f
add third device
jeepies 9893bd1
add coordsToScore util
jeepies 543d432
setup route for /cats/leaderboard/:range
jeepies 00a36fd
added controller
jeepies acd9884
add model logic
jeepies 0bda03d
add primitive tests
jeepies 9471a3a
package: install jest-sorted
jeepies c9723e8
setup jest-sorted with jest and types
jeepies b29e34e
added test for sorted data
jeepies 1e7b2d6
Revert "remove error throwing from middleware"
jeepies 1caf2da
Revert "remove error from controller"
jeepies f68aff5
add Coordinate type
jeepies 8db2d4e
change all_time to setTime
jeepies 96760d3
fixed incorrect useage of .filter() method
jeepies 553ee96
Merge branch 'main' of github.com:clowder-cloud/backend into CL-103-s…
jeepies 8c04d9f
revert usernameAuth
jeepies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ module.exports = { | |
| transform: { | ||
| '^.+.tsx?$': ['ts-jest', {}], | ||
| }, | ||
| setupFilesAfterEnv: ['jest-sorted'], | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| type Coordinate = [number, number]; | ||
|
|
||
| export default Coordinate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| type LocationHistoryType = { lat: number; lon: number }[]; | ||
| type LocationHistoryType = { lat: number; lon: number; timestamp: string }[]; | ||
|
|
||
| export default LocationHistoryType; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * @author PhilTBatt | ||
| */ | ||
| export default function coordsToScore(coordinates: [number, number][]): number { | ||
| const earthRadiusPerDegree = 111000; | ||
jeepies marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let totalLength = 0; | ||
|
|
||
| for (let i = 0; i < coordinates.length - 1; i++) { | ||
| const [lat1, lng1] = coordinates[i]; | ||
| const [lat2, lng2] = coordinates[i + 1]; | ||
|
|
||
| const deltaLat = lat2 - lat1; | ||
| const deltaLng = lng2 - lng1; | ||
stevelw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const deltaLatMeters = deltaLat * earthRadiusPerDegree; | ||
| const deltaLngMeters = | ||
| deltaLng * earthRadiusPerDegree * Math.cos((lat1 * Math.PI) / 180); | ||
|
|
||
| totalLength += Math.sqrt( | ||
| deltaLatMeters * deltaLatMeters + deltaLngMeters * deltaLngMeters | ||
| ); | ||
| } | ||
|
|
||
| return totalLength; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.