@drodil/backstage-plugin-qeta-backend 3.45.2 → 3.47.2

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.
@@ -324,7 +324,8 @@ class DatabaseQetaStore {
324
324
  type: type ?? "question",
325
325
  headerImage,
326
326
  url,
327
- status
327
+ status,
328
+ published: status === "active" ? created : null
328
329
  },
329
330
  ["id"]
330
331
  ).into("posts").returning([
@@ -413,6 +414,8 @@ class DatabaseQetaStore {
413
414
  opts,
414
415
  status = "active"
415
416
  } = options;
417
+ const currentPost = await this.db("posts").select("status", "published").where("id", "=", id).first();
418
+ const shouldSetPublished = currentPost && currentPost.status === "draft" && status === "active" && !currentPost.published;
416
419
  const query = this.db("posts").where("posts.id", "=", id);
417
420
  const rows = await query.update({
418
421
  title,
@@ -422,7 +425,8 @@ class DatabaseQetaStore {
422
425
  url,
423
426
  updatedBy: setUpdatedBy ? user_ref : void 0,
424
427
  updated: setUpdatedBy ? /* @__PURE__ */ new Date() : void 0,
425
- status
428
+ status,
429
+ published: shouldSetPublished ? /* @__PURE__ */ new Date() : void 0
426
430
  });
427
431
  if (!rows) {
428
432
  return null;
@@ -1762,7 +1766,8 @@ class DatabaseQetaStore {
1762
1766
  headerImage: val.headerImage,
1763
1767
  url: val.url ?? void 0,
1764
1768
  images: additionalInfo[5]?.map((r) => r.id),
1765
- experts: additionalInfo[6]
1769
+ experts: additionalInfo[6],
1770
+ published: val.published ? val.published : void 0
1766
1771
  };
1767
1772
  }
1768
1773
  mapComment(val) {