Fixed ordering of published posts
This commit is contained in:
parent
9b20665d11
commit
deca23b599
8 changed files with 81 additions and 10 deletions
|
|
@ -9,10 +9,10 @@ import (
|
|||
)
|
||||
|
||||
// postIter returns a post iterator which returns posts in reverse chronological order.
|
||||
func (s *Publisher) postIter(ctx context.Context, site int64) iter.Seq[models.Maybe[*models.Post]] {
|
||||
func (s *Publisher) publishedPostIter(ctx context.Context, site int64) iter.Seq[models.Maybe[*models.Post]] {
|
||||
return func(yield func(models.Maybe[*models.Post]) bool) {
|
||||
paging := db.PagingParams{Offset: 0, Limit: 50}
|
||||
page, err := s.db.SelectPostsOfSite(ctx, site, false, paging)
|
||||
page, err := s.db.SelectPublishedPostsOfSite(ctx, site, paging)
|
||||
if err != nil {
|
||||
yield(models.Maybe[*models.Post]{Err: err})
|
||||
return
|
||||
|
|
@ -45,7 +45,7 @@ func (s *Publisher) postIterByCategory(ctx context.Context, categoryID int64) it
|
|||
return func(yield func(models.Maybe[*models.Post]) bool) {
|
||||
paging := db.PagingParams{Offset: 0, Limit: 50}
|
||||
for {
|
||||
page, err := s.db.SelectPostsOfCategory(ctx, categoryID, paging)
|
||||
page, err := s.db.SelectPublishedPostsOfCategory(ctx, categoryID, paging)
|
||||
if err != nil {
|
||||
yield(models.Maybe[*models.Post]{Err: err})
|
||||
return
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func (p *Publisher) Publish(ctx context.Context, site models.Site) error {
|
|||
pubSite := pubmodel.Site{
|
||||
Site: site,
|
||||
PostIter: func(ctx context.Context) iter.Seq[models.Maybe[*models.Post]] {
|
||||
return p.postIter(ctx, site.ID)
|
||||
return p.publishedPostIter(ctx, site.ID)
|
||||
},
|
||||
BaseURL: target.BaseURL,
|
||||
Uploads: uploads,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue