fix: don't show redirected posts
Some checks failed
.NET / Build & Test (push) Failing after 1m4s

This commit is contained in:
Oliver Booth 2024-04-26 17:30:42 +01:00
parent 0b1066c273
commit e548758608
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5

View File

@ -45,7 +45,7 @@ internal sealed class BlogPostService : IBlogPostService
{ {
using BlogContext context = _dbContextFactory.CreateDbContext(); using BlogContext context = _dbContextFactory.CreateDbContext();
IQueryable<BlogPost> ordered = context.BlogPosts IQueryable<BlogPost> ordered = context.BlogPosts
.Where(p => p.Visibility == Visibility.Published) .Where(p => p.Visibility == Visibility.Published && !p.IsRedirect)
.OrderByDescending(post => post.Published); .OrderByDescending(post => post.Published);
if (limit > -1) if (limit > -1)
{ {
@ -60,7 +60,7 @@ internal sealed class BlogPostService : IBlogPostService
{ {
using BlogContext context = _dbContextFactory.CreateDbContext(); using BlogContext context = _dbContextFactory.CreateDbContext();
return context.BlogPosts return context.BlogPosts
.Where(p => p.Visibility == Visibility.Published) .Where(p => p.Visibility == Visibility.Published && !p.IsRedirect)
.OrderByDescending(post => post.Published) .OrderByDescending(post => post.Published)
.Skip(page * pageSize) .Skip(page * pageSize)
.Take(pageSize) .Take(pageSize)
@ -72,7 +72,7 @@ internal sealed class BlogPostService : IBlogPostService
{ {
using BlogContext context = _dbContextFactory.CreateDbContext(); using BlogContext context = _dbContextFactory.CreateDbContext();
return context.BlogPosts return context.BlogPosts
.Where(p => p.Visibility == Visibility.Published) .Where(p => p.Visibility == Visibility.Published && !p.IsRedirect)
.OrderBy(post => post.Published) .OrderBy(post => post.Published)
.FirstOrDefault(post => post.Published > blogPost.Published); .FirstOrDefault(post => post.Published > blogPost.Published);
} }
@ -82,7 +82,7 @@ internal sealed class BlogPostService : IBlogPostService
{ {
using BlogContext context = _dbContextFactory.CreateDbContext(); using BlogContext context = _dbContextFactory.CreateDbContext();
return context.BlogPosts return context.BlogPosts
.Where(p => p.Visibility == Visibility.Published) .Where(p => p.Visibility == Visibility.Published && !p.IsRedirect)
.OrderByDescending(post => post.Published) .OrderByDescending(post => post.Published)
.FirstOrDefault(post => post.Published < blogPost.Published); .FirstOrDefault(post => post.Published < blogPost.Published);
} }