Skip to content

Commit

Permalink
fix: fix creation.update_content and search output
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 25, 2023
1 parent 658b1ae commit ef6c4f6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 45 deletions.
80 changes: 40 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "writing"
version = "1.0.3"
version = "1.0.4"
edition = "2021"
rust-version = "1.64"
description = ""
Expand Down
2 changes: 2 additions & 0 deletions src/api/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub async fn original_search(
cid: to.with(doc.cid),
language: to.with(doc.language),
version: doc.version,
updated_at: doc.updated_at,
kind: 1,
title: doc.title,
summary: doc.summary,
Expand All @@ -139,6 +140,7 @@ pub async fn original_search(
cid: to.with(doc.id),
language: to.with(doc.language),
version: doc.version,
updated_at: doc.updated_at,
kind: 0,
title: doc.title,
summary: doc.summary,
Expand Down
3 changes: 3 additions & 0 deletions src/db/meili.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub struct DocumentOutput {
pub cid: PackObject<xid::Id>,
pub language: PackObject<Language>,
pub version: i16,
pub updated_at: i64,
pub kind: i8, // 0: creation, 1: publication
pub title: String,
pub summary: String,
Expand All @@ -81,6 +82,7 @@ impl DocumentOutput {
cid: to.with(cid.unwrap()),
language: to.with(language.unwrap()),
version: val.version,
updated_at: val.updated_at,
kind: val.kind,
title: val.title.unwrap_or_default(),
summary: val.summary.unwrap_or_default(),
Expand Down Expand Up @@ -116,6 +118,7 @@ pub struct SearchOutput {
// "language",
// "kind",
// "version",
// "updated_at",
// "title",
// "summary"
// ],
Expand Down
6 changes: 2 additions & 4 deletions src/db/model_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,13 @@ impl Creation {
}

let mut doc = Content::with_pk(self.content);
doc.update_content(db, self.version + 1, self.language, content.clone())
doc.update_content(db, self.version, self.language, content.clone())
.await?;

let query =
"UPDATE creation SET updated_at=?,version=?,language=? WHERE gid=? AND id=? IF updated_at=?";
"UPDATE creation SET updated_at=?,language=? WHERE gid=? AND id=? IF updated_at=?";
let params = (
doc.updated_at,
doc.version,
self.language.to_cql(),
self.gid.to_cql(),
self.id.to_cql(),
Expand All @@ -468,7 +467,6 @@ impl Creation {
}

self.updated_at = doc.updated_at;
self.version = doc.version;
self._content = content;
Ok(true)
}
Expand Down

0 comments on commit ef6c4f6

Please sign in to comment.