Skip to content

Commit

Permalink
fix: fix count_published_by_gid
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 3, 2023
1 parent 5f51ce4 commit 35c6b80
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 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.1.2"
version = "1.1.4"
edition = "2021"
rust-version = "1.64"
description = ""
Expand Down
4 changes: 3 additions & 1 deletion cmd/sync-to-publication-index/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ async fn main() -> anyhow::Result<()> {
.with_target_writer("*", new_writer(io::stdout()))
.init();

let nodes = std::env::var("SCYLLA_NODES").unwrap_or_else(|_| "127.0.0.1:9042".into());
let nodes = std::env::var("SCYLLA_NODES").expect(
"env SCYLLA_NODES required:\nSCYLLA_NODES=127.0.0.1:9042 ./sync-to-publication-index",
);

let cfg = conf::ScyllaDB {
nodes: nodes.split(',').map(|s| s.to_string()).collect(),
Expand Down
16 changes: 13 additions & 3 deletions src/db/model_publication.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use isolang::Language;
use std::{collections::HashSet, convert::From};

use scylla_orm::{ColumnsMap, CqlValue, ToCqlVal};
use scylla_orm::{ColumnsMap, CqlValue, FromCqlVal, ToCqlVal};
use scylla_orm_macros::CqlOrm;

use crate::db::{
Expand Down Expand Up @@ -268,10 +268,20 @@ impl PublicationIndex {
return Ok(0);
}

let query = "SELECT cid FROM pub_index WHERE gid=? GROUP BY cid USING TIMEOUT 3s";
let query = "SELECT cid FROM pub_index WHERE gid=? GROUP BY day, cid USING TIMEOUT 3s";
let params = (gid.to_cql(),);
let rows = db.execute_iter(query, params).await?;
Ok(rows.len())
let mut cids: HashSet<xid::Id> = HashSet::new();
for row in rows {
if let Some(v) = row.columns.first() {
if let Some(v) = v {
let cid = xid::Id::from_cql(v)?;
cids.insert(cid);
}
}
}

Ok(cids.len())
}
}

Expand Down

0 comments on commit 35c6b80

Please sign in to comment.