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
@@ -1,5 +1,7 @@
|
||||
package article
|
||||
|
||||
import "math"
|
||||
|
||||
const (
|
||||
StatusOnline = "online"
|
||||
StatusDraft = "draft"
|
||||
@@ -37,13 +39,23 @@ type Filters struct {
|
||||
Size int
|
||||
Q string
|
||||
Status string
|
||||
Lang *string
|
||||
SEOStatus string
|
||||
Lang string
|
||||
Langs *[]string
|
||||
AuthorID *uint32
|
||||
Sort Sort
|
||||
Unpaged bool
|
||||
}
|
||||
|
||||
func (f Filters) Window() (int, int) {
|
||||
size := max(f.Size, 0)
|
||||
skipped := max(f.Page, 1) - 1
|
||||
if size > 0 && skipped > math.MaxInt/size {
|
||||
return math.MaxInt, size
|
||||
}
|
||||
return skipped * size, size
|
||||
}
|
||||
|
||||
type Nullable[T any] struct {
|
||||
Set bool
|
||||
Value *T
|
||||
@@ -97,10 +109,7 @@ type Repository interface {
|
||||
CountByVisibility(onlineOnly bool) (Counts, error)
|
||||
CountVisibleTo(userID uint32) (Counts, error)
|
||||
CountVersions(filters Filters) (Counts, error)
|
||||
FindStoryPage(filters StoryFilters) (StoryPage, error)
|
||||
CountStories(filters StoryFilters) (StoryCounts, error)
|
||||
ListByStories(storyIDs []uint32, readable StoryFilters) ([]Article, error)
|
||||
FindTitleMatches(q string, readable StoryFilters) ([]uint32, error)
|
||||
CountSuggestions(filters Filters) (int, error)
|
||||
Get(id uint32) (Article, error)
|
||||
GetByName(name string) (Article, error)
|
||||
GetByLangSlug(siteID uint32, lang string, slug string) (Article, error)
|
||||
@@ -120,4 +129,26 @@ type Repository interface {
|
||||
AssignUnassignedLanguage(siteID uint32, lang string) (int, error)
|
||||
ListByStory(storyID uint32) ([]Article, error)
|
||||
MoveToSite(ids []uint32, siteID uint32) error
|
||||
DeleteStory(storyID uint32) error
|
||||
}
|
||||
|
||||
type StoryReader interface {
|
||||
FindStoryPage(filters StoryFilters) (StoryPage, error)
|
||||
CountStories(filters StoryFilters) (StoryCounts, error)
|
||||
CountSuggestedStories(readable StoryFilters) (int, error)
|
||||
ListByStories(storyIDs []uint32, readable StoryFilters) ([]Article, error)
|
||||
ListVersions(ids []uint32) ([]Article, error)
|
||||
FindTitleMatches(q string, readable StoryFilters) ([]uint32, error)
|
||||
}
|
||||
|
||||
type SEOIndex interface {
|
||||
StaleSEO(afterID uint32, limit int) ([]Article, error)
|
||||
StoreSEO(records []SEORecord) error
|
||||
MarkSiteSEOStale(siteID uint32) error
|
||||
}
|
||||
|
||||
type ListingRepository interface {
|
||||
Repository
|
||||
StoryReader
|
||||
SEOIndex
|
||||
}
|
||||
Reference in new issue
Block a user