Skip to content

Commit

Permalink
[BUG] sidebar results are not correct (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Numkil authored Sep 6, 2024
2 parents 973ba8b + 5711fe9 commit 011ec18
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/services/StatsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class StatsService extends Component
{
public function getDataForEntry(Entry $entry): SiteStatisticsModel|bool
{
$record = SiteStatisticsRecord::findOne(['entryId' => $entry->id, 'siteId' => $entry->siteId]);

if (!$record) {
// Search again without the siteId
$record = SiteStatisticsRecord::findOne(['entryId' => $entry->id]);
if (!$record) {
/** @var SiteStatisticsRecord|null $record */
$record = SiteStatisticsRecord::find()->where(['entryId' => $entry->id])->andWhere(['siteId' => $entry->siteId])->orderBy('id DESC')->one();

// INFO: if we don't find a record, we'll try to find one without the siteId
if ($record === null) {
/** @var SiteStatisticsRecord|null $record */
$record = SiteStatisticsRecord::find()->where(['entryId' => $entry->id])->orderBy('id DESC')->one();
if ($record === null) {
return false;
}
}
Expand Down

0 comments on commit 011ec18

Please sign in to comment.