Skip to content

Commit

Permalink
[backend] Fix logic of latest stats (#8)
Browse files Browse the repository at this point in the history
* Fix logic of latest stats

* Updates
  • Loading branch information
Zhbert authored Aug 28, 2024
1 parent bcc577a commit 7a2c01e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/db_service/habr_sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,18 @@ func GetLatestStatsFromArticle(articleID uint) ([]domain.HabrStats, bool) {
state = true
db.
Where("habr_article_id = ?", articleID).
Order("date_of_stats").
Order("date_of_stats DESC").
Find(&stats).
Limit(2)
}

if len(stats) > 1 {
var newStats []domain.HabrStats
newStats = append(newStats, stats[1])
newStats = append(newStats, stats[0])
return newStats, state
}

return stats, state
}

Expand Down

0 comments on commit 7a2c01e

Please sign in to comment.