@drodil/backstage-plugin-qeta-backend 3.43.0 → 3.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1748,6 +1748,7 @@ class DatabaseQetaStore {
1748
1748
  views: this.mapToInteger(val.views),
1749
1749
  answersCount: this.mapToInteger(val.answersCount),
1750
1750
  correctAnswer: this.mapToInteger(val.correctAnswers) > 0,
1751
+ commentsCount: this.mapToInteger(val.commentsCount),
1751
1752
  favorite: this.mapToInteger(val.favorite) > 0,
1752
1753
  tags: additionalInfo[0],
1753
1754
  answers: additionalInfo[1],
@@ -1915,8 +1916,17 @@ class DatabaseQetaStore {
1915
1916
  if (includeStatusFilter) {
1916
1917
  correctAnswers.where("answers.status", "=", "active");
1917
1918
  }
1919
+ const commentsCount = this.db("comments").where("comments.postId", postRef).count("*").as("commentsCount");
1918
1920
  const favorite = this.db("user_favorite").where("user_favorite.user", "=", user).where("user_favorite.postId", postRef).count("*").as("favorite");
1919
- return this.db("posts").select("posts.*", score, views, answersCount, correctAnswers, favorite).leftJoin("post_votes", "posts.id", "post_votes.postId").leftJoin("post_views", "posts.id", "post_views.postId").leftJoin("answers", "posts.id", "answers.postId").leftJoin("user_favorite", "posts.id", "user_favorite.postId").groupBy("posts.id");
1921
+ return this.db("posts").select(
1922
+ "posts.*",
1923
+ score,
1924
+ views,
1925
+ answersCount,
1926
+ correctAnswers,
1927
+ commentsCount,
1928
+ favorite
1929
+ ).leftJoin("post_votes", "posts.id", "post_votes.postId").leftJoin("post_views", "posts.id", "post_views.postId").leftJoin("answers", "posts.id", "answers.postId").leftJoin("comments", "posts.id", "comments.postId").leftJoin("user_favorite", "posts.id", "user_favorite.postId").groupBy("posts.id");
1920
1930
  }
1921
1931
  getCollectionsBaseQuery() {
1922
1932
  const collectionRef = this.db.ref("collections.id");