Code Duplication    Length = 14-15 lines in 3 locations

core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 3 locations

@@ 189-203 (lines=15) @@
186
        return $data;
187
    }
188
189
    public function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
190
    {
191
        $req = "SELECT expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS distime, pokemon_id as pokemon_id, TO_TIMESTAMP(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
192
                cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
193
                ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form
194
                FROM sightings
195
	            WHERE pokemon_id = '".$pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0'
196
	            ORDER BY $top_order_by $top_direction, expire_timestamp DESC
197
	            LIMIT 50 OFFSET 0";
198
        $result = pg_query($this->db, $req);
199
        $top = array();
200
        while ($data = pg_fetch_object($result)) {
201
            $top[] = $data;
202
        }
203
204
        return $top;
205
    }
206
@@ 533-546 (lines=14) @@
530
        return array('last_page' => $last_page, 'data' => $history);
531
    }
532
533
    private function getHistoryForGymPokemon($gym_id, $last_modified)
534
    {
535
        $req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
536
					FROM gym_history_defenders ghd
537
					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
538
					WHERE ghd.fort_id = '".$gym_id."' AND date = '".$last_modified."'
539
					ORDER BY gd.deployment_time";
540
        $result = pg_query($this->db, $req);
541
        $pokemons = array();
542
        while ($data = pg_fetch_object($result)) {
543
            $pokemons[$data->defender_id] = $data;
544
        }
545
546
        return $pokemons;
547
    }
548
549
    ///////////
@@ 553-567 (lines=15) @@
550
    // Raids
551
    ///////////
552
553
    public function getAllRaids($page)
554
    {
555
        $limit = ' LIMIT 10 OFFSET '.($page * 10);
556
        $req = 'SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude
557
					FROM forts f
558
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
559
				 	LEFT JOIN raids r ON (r.fort_id = f.id AND r.time_end >= UNIX_TIMESTAMP())
560
					WHERE r.time_end > EXTRACT(EPOCH FROM NOW())
561
					ORDER BY r.level DESC, r.time_battle'.$limit;
562
        $result = pg_query($this->db, $req);
563
        $raids = array();
564
        while ($data = pg_fetch_object($result)) {
565
            $raids[] = $data;
566
        }
567
568
        return $raids;
569
    }
570