Skip to content

Commit

Permalink
fix: fix subscription's expire_at
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 22, 2023
1 parent 91f1f3a commit 4334562
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 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.3.4"
version = "1.3.5"
edition = "2021"
rust-version = "1.64"
description = ""
Expand Down
4 changes: 2 additions & 2 deletions cql/schema_table.cql
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ CREATE TABLE IF NOT EXISTS collection_subscription (
cid BLOB, -- collection id, 12 bytes XID
txn BLOB, -- latest subscription transaction id, 12 bytes XID
updated_at BIGINT, -- updated at, unix time, ms
expire_at BIGINT, -- subscription expire at, unix time, ms
expire_at BIGINT, -- subscription expire at, unix time, second!!
PRIMARY KEY (uid, cid)
) WITH CLUSTERING ORDER BY (cid DESC)
AND caching = {'enabled': 'true'}
Expand All @@ -167,7 +167,7 @@ CREATE TABLE IF NOT EXISTS creation_subscription (
cid BLOB, -- creation id, 12 bytes XID
txn BLOB, -- latest subscription transaction id, 12 bytes XID
updated_at BIGINT, -- updated at, unix time, ms
expire_at BIGINT, -- subscription expire at, unix time, ms
expire_at BIGINT, -- subscription expire at, unix time, second!!
PRIMARY KEY (uid, cid)
) WITH CLUSTERING ORDER BY (cid DESC)
AND caching = {'enabled': 'true'}
Expand Down
4 changes: 2 additions & 2 deletions src/api/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub async fn get(
}
}
Some(ref sub) => {
if sub.expire_at < ctx.unix_ms as i64 {
if sub.expire_at * 1000 < ctx.unix_ms as i64 {
output.rfp = Some(RFP {
creation: None,
collection: Some(price),
Expand Down Expand Up @@ -1095,7 +1095,7 @@ pub async fn list_by_child(
let mut output = CollectionOutput::from(doc, &to);
match subscription {
Some(s) => {
if s.expire_at < ctx.unix_ms as i64 {
if s.expire_at * 1000 < ctx.unix_ms as i64 {
output.rfp = Some(RFP {
creation: None,
collection: Some(price),
Expand Down
5 changes: 3 additions & 2 deletions src/api/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ async fn try_get_subscription(
}

let mut subscription = db::CreationSubscription::with_pk(uid, creation.id);
if subscription.get_one(scylla, vec![]).await.is_ok() && subscription.expire_at >= now_ms {
if subscription.get_one(scylla, vec![]).await.is_ok() && subscription.expire_at * 1000 >= now_ms
{
return (None, Some(subscription));
}

Expand Down Expand Up @@ -451,7 +452,7 @@ async fn try_get_subscription(
.get_one(scylla, vec!["expire_at".to_string()])
.await
.is_ok()
&& doc.expire_at >= now_ms
&& doc.expire_at * 1000 >= now_ms
{
return (None, subscription);
}
Expand Down

0 comments on commit 4334562

Please sign in to comment.