change the blogs service

This commit is contained in:
Pouya Defaei
2026-05-22 21:07:51 +03:30
parent a94a46ad98
commit f36385c53f

View File

@@ -284,21 +284,15 @@ export class BlogsService {
async fetchLastBlogsByLanguage(language: LanguageEnum): Promise<Blog[]> {
const blogs = await this.blogsRepository
.createQueryBuilder("b")
.leftJoin("b.translations", "t", "t.language = :language", { language })
.leftJoin("b.writer", "w")
.select("b.id", "id")
.addSelect("b.featuredImage", "featuredImage")
.addSelect("b.href", "href")
.addSelect("b.publishedAt", "publishedAt")
.addSelect("t.title", "title")
.addSelect("t.description", "description")
.addSelect("w.username", "writer")
.where("b.deletedAt IS NULL")
.andWhere("b.publishedAt IS NOT NULL")
.orderBy("b.publishedAt", "DESC")
.createQueryBuilder("blog")
.select(["blog.id", "blog.featuredImage", "blog.gallery", "blog.href", "blog.publishedAt", "blog.createdAt"])
.leftJoinAndSelect("blog.translations", "translation", "translation.language = :language", { language })
.leftJoinAndSelect("blog.writer", "writer")
.where("blog.deletedAt IS NULL")
.andWhere("blog.publishedAt IS NOT NULL")
.orderBy("blog.publishedAt", "DESC")
.limit(3)
.getRawMany();
.getMany();
return blogs;
}