Skip to content
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

Add detailed invasion stats in the sidebar (async) #316

Merged
merged 2 commits into from
Sep 7, 2023
Merged
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
22 changes: 15 additions & 7 deletions static/js/map/map.stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function updateStatsTable() {
if (selectedTab === '#pokestop-stats-tab') {
let noStatusCount = 0
let questCount = 0
let invasionCount = 0
let invasionCounts = {}
let normalLureCount = 0
let glacialLureCount = 0
let magneticLureCount = 0
Expand All @@ -448,7 +448,15 @@ function updateStatsTable() {
hasStatus = true
}
if (isPokestopMeetsInvasionFilters(pokestop)) {
invasionCount++
if ( !(pokestop.incident_grunt_type in invasionCounts) ) {
let invDesc = 'Unknown Invasion'
if (pokestop.incident_grunt_type != 0) {
invDesc = `${getInvasionType(pokestop.incident_grunt_type)} ${getInvasionGrunt(pokestop.incident_grunt_type)}`
}
invasionCounts[pokestop.incident_grunt_type] = [1, getPokestopIconUrl(pokestop), invDesc]
} else {
invasionCounts[pokestop.incident_grunt_type][0] += 1
}
hasStatus = true
}
if (isPokestopMeetsLureFilters(pokestop)) {
Expand Down Expand Up @@ -501,13 +509,13 @@ function updateStatsTable() {
]
)
}
if (invasionCount > 0) {
for (let invNum in invasionCounts) {
pokestopRows.push(
[
'<img src="static/images/pokestop/stop_i.png" width=32 />',
i18n('Rocket Invasion'),
invasionCount,
(invasionCount * 100) / pokestopCount
`<img src="${invasionCounts[invNum][1]}" width=32 />`,
i18n(invasionCounts[invNum][2]),
invasionCounts[invNum][0],
(invasionCounts[invNum][0] * 100) / pokestopCount
]
)
}
Expand Down