refac: article reads, story delete, no leaks, stored SEO status, rate limit, cleanup (%site%, article repo split, old lang repos, one default per site rule to domain)
This commit is contained in:
1 parent
9d284e65a9
commit
7c15206170
85 files changed
+1788
-593
No files matched your search
@@ -38,6 +38,7 @@ type mockArticleRepo struct {
|
||||
onGet func(id uint32) error
|
||||
reverseStory bool
|
||||
listCalls int
|
||||
assessed map[uint32]assessedVersion
|
||||
}
|
||||
|
||||
func newMockArticleRepo() *mockArticleRepo {
|
||||
@@ -126,7 +127,10 @@ func (m *mockArticleRepo) FindPage(filters article.Filters) (article.PageResult,
|
||||
if filters.Status == article.StatusDraft && a.IsOnline {
|
||||
continue
|
||||
}
|
||||
if filters.Lang != nil && a.Lang != *filters.Lang {
|
||||
if filters.Lang != "" && a.Lang != filters.Lang {
|
||||
continue
|
||||
}
|
||||
if filters.SEOStatus != "" && a.SEO.Status != filters.SEOStatus {
|
||||
continue
|
||||
}
|
||||
if filters.Langs != nil && !slices.Contains(*filters.Langs, a.Lang) {
|
||||
@@ -141,8 +145,9 @@ func (m *mockArticleRepo) FindPage(filters article.Filters) (article.PageResult,
|
||||
matching = append(matching, a)
|
||||
}
|
||||
sort.Slice(matching, func(i, j int) bool { return articleSortsBefore(matching[i], matching[j], filters.Sort) })
|
||||
start := min((filters.Page-1)*filters.Size, len(matching))
|
||||
end := min(start+filters.Size, len(matching))
|
||||
offset, limit := filters.Window()
|
||||
start := min(offset, len(matching))
|
||||
end := start + min(limit, len(matching)-start)
|
||||
if filters.Unpaged {
|
||||
start, end = 0, len(matching)
|
||||
}
|
||||
@@ -176,7 +181,7 @@ func (m *mockArticleRepo) CountVersions(filters article.Filters) (article.Counts
|
||||
}
|
||||
counts := article.Counts{}
|
||||
for _, a := range m.articles {
|
||||
if filters.Lang != nil && a.Lang != *filters.Lang {
|
||||
if filters.Lang != "" && a.Lang != filters.Lang {
|
||||
continue
|
||||
}
|
||||
if a.IsOnline {
|
||||
|
||||
Reference in new issue
Block a user