db query for penalty correct?

Questions, comments, suggestions, and bug reports
Posts: 45
Joined: Sun May 24, 2015 9:39 am
antispam: rimor

db query for penalty correct?

Postby equi » Fri Feb 03, 2017 7:49 pm

im not totally sure, but something doesnt seem right with the penalty command in towerController.php line 1308:

Code: Select all

   protected function getSitesInPenalty($time) {
      $sql = "
         SELECT att_guild_name, att_faction, MAX(IFNULL(t2.time, t1.time)) AS penalty_time
         FROM tower_attack_<myname> t1
            LEFT JOIN tower_victory_<myname> t2 ON t1.id = t2.id
            att_guild_name <> ''
            AND (t2.time IS NULL AND t1.time > ?)
            OR t2.time > ?
         GROUP BY att_guild_name, att_faction
         ORDER BY att_faction ASC, penalty_time DESC";
      return $this->db->query($sql, $time, $time);

shouldnt be the join ON with victory db be with t2.att_id and than it could be another org who got the tower.
Guess there better should be two queries and than union/group them or something like that. But attack id joining a table id from victory db doesnt feel right, guess it uses attack entry anyway cause much more attack entrys than victory entries and so always attack.time>victory.time
Posts: 1892
Joined: Sat Jan 09, 2010 1:32 am

Re: db query for penalty correct?

Postby Tyrence » Fri Feb 10, 2017 7:09 am

I think you are right. The ON clause should be:

Code: Select all

ON t1.id = t2.attack_id

I committed that fix. Thanks.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests