♻️ Refactored feed module

This commit is contained in:
2025-04-05 00:37:00 +08:00
parent 3a8d85684c
commit 2fb98edb83
15 changed files with 295 additions and 286 deletions

View File

@@ -5,18 +5,9 @@ import (
"git.solsynth.dev/hypernet/reader/pkg/internal/models"
)
func GetTodayNewsRandomly(limit int, isAdvanced bool) ([]models.NewsArticle, error) {
var sources []string
for _, srv := range GetNewsSources() {
if !isAdvanced && srv.Advanced {
continue
}
sources = append(sources, srv.ID)
}
var articles []models.NewsArticle
func GetTodayFeedRandomly(limit int) ([]models.SubscriptionItem, error) {
var articles []models.SubscriptionItem
if err := database.C.Limit(limit).
Where("source IN ?", sources).
Where("DATE(created_at) = CURRENT_DATE"). // Created in today
Order("RANDOM()").
Find(&articles).Error; err != nil {