Skip to content

Commit

Permalink
RDM, fixes (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
123FLO321 authored and Obihoernchen committed Apr 2, 2019
1 parent 9cdd6ed commit ee4a778
Show file tree
Hide file tree
Showing 18 changed files with 824 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config.example.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// db server port
define('SYS_DB_PORT', 3306);
// db scanner type
define('SYS_DB_TYPE', 'rocketmap'); // 'rocketmap', 'monocle-alt-mysql' or 'monocle-alt-pgsql'
define('SYS_DB_TYPE', 'rocketmap'); // 'rocketmap', 'realdevicemap', 'monocle-alt-mysql' or 'monocle-alt-pgsql'

// Please, do not touch me, I'm fine ;)

Expand Down
2 changes: 1 addition & 1 deletion core/cron/pokemon.cron.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
$pokemon_stats['timestamp'] = $timestamp;

$pokemon_stats['pokemon_now'] = $manager->getTotalPokemon()->total;
$pokemon_stats['pokemon_now_iv'] = $manager->getTotalPokemonIV()->total;

$counts = $manager->getPokemonCountsActive();

$rarityarray = array();
foreach ($counts as $poke_id => $total) {
$rarity = $pokemons->pokemon->$poke_id->rarity;
Expand Down
33 changes: 32 additions & 1 deletion core/js/dashboard.graph.js.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
$i = 0;
$labels_global = array();
$total = array();
$total_iv = array();
$labels = array();
$veco = array();
$commo = array();
Expand All @@ -61,6 +62,11 @@
if ($data->timestamp > $lastweek) {
$labels_global[] = '"'.date('D H:i', $data->timestamp).'"';
$total[] = $data->pokemon_now;
if (isset($data->pokemon_now_iv)) {
$total_iv[] = $data->pokemon_now_iv;
} else {
$total_iv[] = null;
}
}

if ($data->timestamp > $yesterday) {
Expand Down Expand Up @@ -187,7 +193,32 @@
pointHitRadius: 10,
data: [<?= implode(',', $total); ?>],
spanGaps: false,
}]
}
<?php if ($config->system->dashboard_iv_graph) { ?>
,{
label: '<?= $locales->DASHBOARD_SPAWN_TOTAL_IV; ?>',
fill: true,
lineTension: 0.1,
backgroundColor: 'rgba(0,0,0,0.4)',
borderColor: 'rgba(0,0,0,1)',
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: 'rgba(0,0,0,1)',
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: 'rgba(0,0,0,1)',
pointHoverBorderColor: 'rgba(0,0,0,1)',
pointHoverBorderWidth: 2,
pointRadius: 0,
pointHitRadius: 10,
data: [<?= implode(',', $total_iv); ?>],
spanGaps: false,
}
<?php } ?>
]
};

var myLineChart = new Chart(ctx, {
Expand Down
3 changes: 3 additions & 0 deletions core/json/locales/DE/translations.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
"DASHBOARD_PRESTIGE_AVERAGE": "Durchschnittliche Arena-WP",
"DASHBOARD_SPAWN_TITLE": "Pokémon <strong>Spawns</strong>",
"DASHBOARD_SPAWN_TOTAL": "Spawns gesamt",
"DASHBOARD_SPAWN_TOTAL_IV": "Spawns gesamt mit IV",
"DASHBOARD_SUBTITLE": "Die Daten werden alle <strong>15 Minuten</strong> aktualisiert",
"DASHBOARD_TITLE": "<strong>Statistiken</strong>",
"DATE": "Datum",
"DAY": "Tag",
"TODAY": "Heute",
"YESTERDAY": "Gestern",
"DAYS": "Tagen",
"DEFENSE": "Verteidigung",
"ERROR": "Seite <strong>nicht gefunden</strong><br><small>Irgendwer hat irgendwo einen Fehler verursacht, oder so.</small>",
Expand Down
3 changes: 3 additions & 0 deletions core/json/locales/EN/translations.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
"DASHBOARD_PRESTIGE_AVERAGE": "CP Average Team Performance",
"DASHBOARD_SPAWN_TITLE": "Pokémon <strong>spawn</strong>",
"DASHBOARD_SPAWN_TOTAL": "Total Spawn",
"DASHBOARD_SPAWN_TOTAL_IV": "Total Spawn with IV",
"DASHBOARD_SUBTITLE": "Data are gathered every <strong>15 minutes</strong>",
"DASHBOARD_TITLE": "MOAR <strong>DATA</strong> MOAAAAR",
"DATE": "Date",
"DAY": "day",
"TODAY": "Today",
"YESTERDAY": "Yesterday",
"DAYS": "days",
"DEFENSE": "Defense",
"ERROR": "Page <strong>not found</strong><br><small>There must have been some kind of mistake.</small>",
Expand Down
3 changes: 2 additions & 1 deletion core/json/variables.examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"rm_pokemon_file" : null,
"no_lures" : false,
"homepage_raids" : false,
"gymhistory_hide_cp_changes" : false
"gymhistory_hide_cp_changes" : false,
"dashboard_iv_graph" : true
},
"menu":[
{
Expand Down
2 changes: 1 addition & 1 deletion core/process/aru.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
} else {
$gymData['gymDetails']['gymInfos']['url'] = $data->url;
}
if (null == $data->url) {
if (null == $data->total_cp) {
$gymData['gymDetails']['gymInfos']['points'] = '?';
} else {
$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
Expand Down
1 change: 0 additions & 1 deletion core/process/data.loader.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@
// Recent spawns
// ------------

$recents = array();
if ($config->system->recents_filter) {
// get all mythic pokemon ids
$mythic_pokemons = array();
Expand Down
59 changes: 47 additions & 12 deletions core/process/locales.loader.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@
$pokemons = new stdClass();
$pokemons->pokemon = new stdClass();

$data = $manager->getPokemonCountAll();
$pokemon_counts = array();
foreach ($data as $pokemon) {
$pokemon_counts[$pokemon->pokemon_id] = $pokemon;
}

$data = $manager->getRaidCountAll();
$raid_counts = array();
foreach ($data as $raid) {
$raid_counts[$raid->pokemon_id] = $raid;
}

$totalCountPoke = 0;
$maxpid = $config->system->max_pokemon;
for ($pokeid = 1; $pokeid <= $maxpid; ++$pokeid) {
Expand Down Expand Up @@ -213,13 +225,24 @@
}

// Add pokemon counts to array
$data = $manager->getPokemonCount($pokeid);
if (isset($data->count)) {
if (array_key_exists($pokeid, $pokemon_counts)) {
$data = $pokemon_counts[$pokeid];
$pokemon->spawn_count = $data->count;
$pokemon->last_seen = $data->last_seen;
$pokemon->last_position = new stdClass();
$pokemon->last_position->latitude = $data->latitude;
$pokemon->last_position->longitude = $data->longitude;
if (isset($data->last_seen)) {
$pokemon->last_seen = $data->last_seen;
} else {
$pokemon->last_seen = null;
}
if (isset($data->last_seen_day)) {
$pokemon->last_seen_day = $data->last_seen_day;
} else {
$pokemon->last_seen_day = null;
}
if (isset($data->latitude) && isset($data->longitude)) {
$pokemon->last_position = new stdClass();
$pokemon->last_position->latitude = $data->latitude;
$pokemon->last_position->longitude = $data->longitude;
}

$totalCountPoke += $data->count;
} else {
Expand All @@ -229,13 +252,24 @@
}

// Add raid counts to array
$data = $manager->getRaidCount($pokeid);
if (isset($data->count)) {
if (array_key_exists($pokeid, $raid_counts)) {
$data = $raid_counts[$pokeid];
$pokemon->raid_count = $data->count;
$pokemon->last_raid_seen = $data->last_seen;
$pokemon->last_raid_position = new stdClass();
$pokemon->last_raid_position->latitude = $data->latitude;
$pokemon->last_raid_position->longitude = $data->longitude;
if (isset($data->last_seen)) {
$pokemon->last_raid_seen = $data->last_seen;
} else {
$pokemon->last_raid_seen = null;
}
if (isset($data->last_seen_day)) {
$pokemon->last_raid_seen_day = $data->last_seen_day;
} else {
$pokemon->last_raid_seen_day = null;
}
if (isset($data->latitude) && isset($data->longitude)) {
$pokemon->last_raid_position = new stdClass();
$pokemon->last_raid_position->latitude = $data->latitude;
$pokemon->last_raid_position->longitude = $data->longitude;
}
} else {
$pokemon->raid_count = 0;
$pokemon->last_raid_seen = null;
Expand Down Expand Up @@ -290,6 +324,7 @@
unset($translation_file);
unset($pokedex_file);
unset($pokemon_counts);
unset($raid_counts);
unset($moves_file);
unset($pokemon_trans);
unset($types_temp);
Expand Down
10 changes: 10 additions & 0 deletions core/process/queries/QueryManager.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public static function current()
self::$time_offset = $time_offset;

switch (strtolower(SYS_DB_TYPE)) {
case 'rdm':
case 'realdevicemap':
self::$current = new QueryManagerMysqlRealDeviceMap();
break;
case 'monocle-alt':
case 'monocle-alt-mysql':
self::$current = new QueryManagerMysqlMonocleAlternate();
Expand Down Expand Up @@ -91,8 +95,12 @@ abstract public function getMapsCoords();

abstract public function getPokemonCount($pokemon_id);

abstract public function getPokemonCountAll();

abstract public function getRaidCount($pokemon_id);

abstract public function getRaidCountAll();

// Pokestops
abstract public function getTotalPokestops();

Expand Down Expand Up @@ -127,6 +135,8 @@ abstract public function getTrainerLevelCount($team_id);
// Cron
abstract public function getPokemonCountsActive();

abstract public function getTotalPokemonIV();

abstract public function getPokemonCountsLastDay();

abstract public function getCaptchaCount();
Expand Down
1 change: 1 addition & 0 deletions core/process/queries/QueryManagerMysql.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

include_once __DIR__.'/QueryManagerMysqlRocketmap.php';
include_once __DIR__.'/QueryManagerMysqlMonocleAlternate.php';
include_once __DIR__.'/QueryManagerMysqlRealDeviceMap.php';

abstract class QueryManagerMysql extends QueryManager
{
Expand Down
36 changes: 36 additions & 0 deletions core/process/queries/QueryManagerMysqlMonocleAlternate.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ public function getPokemonCount($pokemon_id)
return $data;
}

public function getPokemonCountAll()
{
$req = 'SELECT pid as pokemon_id, count, last_seen, latitude, longitude
FROM pokemon_stats
GROUP BY pid';
$result = $this->mysqli->query($req);
$array = array();
while ($data = $result->fetch_object()) {
$array[] = $data;
}

return $array;
}

public function getRaidCount($pokemon_id)
{
$req = 'SELECT count, last_seen, latitude, longitude
Expand All @@ -339,6 +353,20 @@ public function getRaidCount($pokemon_id)
return $data;
}

public function getRaidCountAll()
{
$req = 'SELECT pid as pokemon_id, count, last_seen, latitude, longitude
FROM raid_stats
GROUP BY pid';
$result = $this->mysqli->query($req);
$array = array();
while ($data = $result->fetch_object()) {
$array[] = $data;
}

return $array;
}

///////////////
// Pokestops
//////////////
Expand Down Expand Up @@ -719,6 +747,14 @@ public function getPokemonCountsActive()
return $counts;
}

public function getTotalPokemonIV()
{
$req = 'SELECT COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() AND cp IS NOT NULL';
$result = $this->mysqli->query($req);
$data = $result->fetch_object();

return $data;
}
public function getPokemonCountsLastDay()
{
$req = 'SELECT pokemon_id, COUNT(*) AS spawns_last_day
Expand Down
Loading

0 comments on commit ee4a778

Please sign in to comment.