Skip to content

Commit

Permalink
refs matomo-org#4532 easier fix with less logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vagrant committed Jan 30, 2014
1 parent 6644c8d commit 0cd0888
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions core/DataAccess/ArchiveSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,39 +177,20 @@ static public function getArchiveIds($siteIds, $periods, $segment, $plugins)
$bind[] = $firstPeriod->getDateEnd()->toString('Y-m-d');
} else {
// we assume there is no range date in $periods
$dateStrs = array();
$dayPeriod = null;
$dateCondition = '(';

foreach ($periods as $period) {
if ($period instanceof Period\Day) {
$dateStrs[] = $period->getDateStart()->toString('Y-m-d');
$dayPeriod = $period;
if (strlen($dateCondition) > 1) {
$dateCondition .= ' OR ';
}
}

if (!empty($dayPeriod) && !empty($dateStrs)) {
$bind[] = $dayPeriod->getId();
$dateCondition .= "(period = ? AND date1 IN ('" . implode("','", $dateStrs) . "'))";
}

reset($periods);
foreach ($periods as $period) {
if ($period instanceof Period\Week || $period instanceof Period\Month || $period instanceof Period\Year) {

if (strlen($dateCondition) > 5) {
$dateCondition .= ' OR ';
}

$dateCondition .= "(period = ? AND date1 = ? AND date2 = ?)";
$bind[] = $period->getId();
$bind[] = $period->getDateStart()->toString('Y-m-d');
$bind[] = $period->getDateEnd()->toString('Y-m-d');
}
$dateCondition .= "(period = ? AND date1 = ? AND date2 = ?)";
$bind[] = $period->getId();
$bind[] = $period->getDateStart()->toString('Y-m-d');
$bind[] = $period->getDateEnd()->toString('Y-m-d');
}

$dateCondition .= ')';

}

$sql = sprintf($getArchiveIdsSql, $table, $dateCondition);
Expand Down

0 comments on commit 0cd0888

Please sign in to comment.