Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Remove CRDTs from COB state
Alexis Sellier committed 2 years ago
commit 1dc799d679258663de2bd7d2dc31e9f708ab61f4
parent 2e25250be44a687e820c41e6adf64dab98d53e88
3 files changed +16 -15
modified radicle-httpd/src/api/json.rs
@@ -138,7 +138,7 @@ pub(crate) fn patch(
                "discussions": rev.discussion().comments()
                  .map(|(id, comment)| Comment::new(id, comment,  aliases))
                  .collect::<Vec<_>>(),
-
                "timestamp": rev.timestamp(),
+
                "timestamp": rev.timestamp().as_secs().to_string(),
                "reviews": rev.reviews().map(|(nid, _review)| review(nid, aliases.alias(nid), _review)).collect::<Vec<_>>(),
            })
        }).collect::<Vec<_>>(),
@@ -165,7 +165,7 @@ fn merge(merge: &Merge, nid: &NodeId, alias: Option<Alias>) -> Value {
                "alias": alias,
            },
            "commit": merge.commit,
-
            "timestamp": merge.timestamp,
+
            "timestamp": merge.timestamp.as_secs().to_string(),
            "revision": merge.revision,
        }),
        None => json!({
@@ -173,7 +173,7 @@ fn merge(merge: &Merge, nid: &NodeId, alias: Option<Alias>) -> Value {
                "id": nid,
            },
            "commit": merge.commit,
-
            "timestamp": merge.timestamp,
+
            "timestamp": merge.timestamp.as_secs().to_string(),
            "revision": merge.revision,
        }),
    }
@@ -190,7 +190,7 @@ fn review(nid: &NodeId, alias: Option<Alias>, review: &Review) -> Value {
            "verdict": review.verdict(),
            "summary": review.summary(),
            "comments": review.comments().collect::<Vec<_>>(),
-
            "timestamp": review.timestamp(),
+
            "timestamp": review.timestamp().as_secs().to_string(),
        }),
        None => json!({
            "author": {
@@ -199,7 +199,7 @@ fn review(nid: &NodeId, alias: Option<Alias>, review: &Review) -> Value {
            "verdict": review.verdict(),
            "summary": review.summary(),
            "comments": review.comments().collect::<Vec<_>>(),
-
            "timestamp": review.timestamp(),
+
            "timestamp": review.timestamp().as_secs().to_string(),
        }),
    }
}
@@ -240,6 +240,7 @@ struct Comment<'a> {
    author: Value,
    body: &'a str,
    reactions: Vec<(&'a ActorId, &'a Reaction)>,
+
    #[serde(with = "radicle::serde_ext::localtime::time")]
    timestamp: Timestamp,
    reply_to: Option<CommentId>,
}
modified radicle-httpd/src/api/v1/projects.rs
@@ -460,16 +460,16 @@ async fn issues_handler(
    let mut issues: Vec<_> = issues
        .all()?
        .filter_map(|r| {
-
            let (id, issue, clock) = r.ok()?;
-
            (state.matches(issue.state())).then_some((id, issue, clock))
+
            let (id, issue) = r.ok()?;
+
            (state.matches(issue.state())).then_some((id, issue))
        })
        .collect::<Vec<_>>();

-
    issues.sort_by(|(_, a, _), (_, b, _)| b.timestamp().cmp(&a.timestamp()));
+
    issues.sort_by(|(_, a), (_, b)| b.timestamp().cmp(&a.timestamp()));
    let aliases = &ctx.profile.aliases();
    let issues = issues
        .into_iter()
-
        .map(|(id, issue, _)| api::json::issue(id, issue, aliases))
+
        .map(|(id, issue)| api::json::issue(id, issue, aliases))
        .skip(page * per_page)
        .take(per_page)
        .collect::<Vec<_>>();
@@ -739,15 +739,15 @@ async fn patches_handler(
    let mut patches = patches
        .all()?
        .filter_map(|r| {
-
            let (id, patch, clock) = r.ok()?;
-
            (state.matches(patch.state())).then_some((id, patch, clock))
+
            let (id, patch) = r.ok()?;
+
            (state.matches(patch.state())).then_some((id, patch))
        })
        .collect::<Vec<_>>();
-
    patches.sort_by(|(_, a, _), (_, b, _)| b.timestamp().cmp(&a.timestamp()));
+
    patches.sort_by(|(_, a), (_, b)| b.timestamp().cmp(&a.timestamp()));
    let aliases = ctx.profile.aliases();
    let patches = patches
        .into_iter()
-
        .map(|(id, patch, _)| api::json::patch(id, patch, &repo, &aliases))
+
        .map(|(id, patch)| api::json::patch(id, patch, &repo, &aliases))
        .skip(page * per_page)
        .take(per_page)
        .collect::<Vec<_>>();
modified radicle-httpd/src/test.rs
@@ -37,7 +37,7 @@ pub const ISSUE_ID: &str = "5ad77fa3f476beed9a26f49b2b3b844e61bef792";
pub const ISSUE_DISCUSSION_ID: &str = "f1dff128a22e8183a23516dd9812e72e80914c92";
pub const ISSUE_COMMENT_ID: &str = "845218041bf9eb8155bfa4aaa8f0c91ce18e5c13";
pub const SESSION_ID: &str = "u9MGAkkfkMOv0uDDB2WeUHBT7HbsO2Dy";
-
pub const TIMESTAMP: u64 = 1671125284;
+
pub const TIMESTAMP: &str = "1671125284";
pub const CONTRIBUTOR_RID: &str = "rad:z4XaCmN3jLSeiMvW15YTDpNbDHFhG";
pub const CONTRIBUTOR_DID: &str = "did:key:z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8";
pub const CONTRIBUTOR_NID: &str = "z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8";
@@ -97,7 +97,7 @@ fn seed_with_signer<G: Signer>(dir: &Path, profile: radicle::Profile, signer: &G

    let workdir = dir.join("hello-world");

-
    env::set_var("RAD_COMMIT_TIME", TIMESTAMP.to_string());
+
    env::set_var("RAD_COMMIT_TIME", TIMESTAMP);

    fs::create_dir_all(&workdir).unwrap();