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
@@ -25,6 +25,13 @@ type countingStoryRepository struct {
|
||||
*persistence.ArticleRepository
|
||||
titleSearches int
|
||||
pageLoads int
|
||||
staleReads int
|
||||
}
|
||||
|
||||
func (r *countingStoryRepository) StaleSEO(afterID uint32, limit int) ([]domainArticle.Article, error) {
|
||||
stale, err := r.ArticleRepository.StaleSEO(afterID, limit)
|
||||
r.staleReads += len(stale)
|
||||
return stale, err
|
||||
}
|
||||
|
||||
func (r *countingStoryRepository) FindTitleMatches(q string, readable domainArticle.StoryFilters) ([]uint32, error) {
|
||||
@@ -78,7 +85,14 @@ func TestArticleStoryListSEOFilterAtScaleSQLite(t *testing.T) {
|
||||
site := storageDefaultSite(t, db)
|
||||
seedSEOScale(t, db, site.ID)
|
||||
repository := &countingStoryRepository{ArticleRepository: persistence.NewArticleRepository(db)}
|
||||
list := useCases.NewListArticlesUseCase(repository, &fakeBodyRenderer{}, persistence.NewSiteRepository(db), persistence.NewLocalizationRepository(db))
|
||||
sites, rows := persistence.NewSiteRepository(db), persistence.NewLocalizationRepository(db)
|
||||
if err := useCases.NewRefreshArticleSEOUseCase(repository, sites, rows).RefreshStale(); err != nil {
|
||||
t.Fatalf("backfill: %v", err)
|
||||
}
|
||||
if repository.staleReads != seoScaleVersions {
|
||||
t.Fatalf("the backfill assessed %d versions, want %d", repository.staleReads, seoScaleVersions)
|
||||
}
|
||||
list := useCases.NewListArticlesUseCase(repository, &fakeBodyRenderer{}, sites, rows)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
@@ -93,7 +107,7 @@ func TestArticleStoryListSEOFilterAtScaleSQLite(t *testing.T) {
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
repository.titleSearches, repository.pageLoads = 0, 0
|
||||
repository.titleSearches, repository.pageLoads, repository.staleReads = 0, 0, 0
|
||||
want := expectedSEOScale(c.hidden, c.titled)
|
||||
|
||||
page, err := list.ListStoriesPage(useCases.ListStoriesCommand{Caller: ownerCaller(1), Page: 2, Size: seoScalePageSize, SEO: c.seo, Q: c.q})
|
||||
@@ -116,8 +130,8 @@ func TestArticleStoryListSEOFilterAtScaleSQLite(t *testing.T) {
|
||||
if c.q != "" {
|
||||
wantSearches = 1
|
||||
}
|
||||
if repository.titleSearches != wantSearches || repository.pageLoads != 1 {
|
||||
t.Errorf("title searches %d, page loads %d per request", repository.titleSearches, repository.pageLoads)
|
||||
if repository.titleSearches != wantSearches || repository.pageLoads != 0 || repository.staleReads != 0 {
|
||||
t.Errorf("title searches %d, page loads %d, stale versions read %d per request", repository.titleSearches, repository.pageLoads, repository.staleReads)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user