Skip to content

Commit

Permalink
Merge pull request #32 from lightningrodlabs/minor-refactor
Browse files Browse the repository at this point in the history
Minor refactor
  • Loading branch information
weswalla authored Mar 3, 2022
2 parents 57ce636 + 4bfbac3 commit 2836b12
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 128 deletions.
107 changes: 50 additions & 57 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[package]
name = "hdk_crud"
description = "A library to help quickly and easily create a consistent set of create-read-update-delete functions for an Entry type in Holochain, complete with signaling options"
version = "0.5.4"
version = "0.5.5"
license = "CAL-1.0"
repository = "https://github.com/lightningrodlabs/hdk_crud"
authors = ["Connor Turland <[email protected]>"]
edition = "2018"

[dependencies]
hdk = "0.0.115"
holo_hash = { version = "0.0.12", features = ["encoding"] }
hdk = "0.0.122"
holo_hash = { version = "0.0.19", features = ["encoding"] }
paste = "1.0.5"
serde = "1.0.123"
thiserror = "1"
mockall = "0.9"
fixt = { version = "0.0.7", optional = true }
fixt = { version = "0.0.8", optional = true }
mockall_double = { version = "0.2.0", optional = true }
chrono = "0.4.19"
assert_matches = "1.5.0"
holochain_types = { version = "0.0.15", optional = true }
holochain_types = { version = "0.0.26", optional = true }

[dev-dependencies]
rand = "0.7"
Expand Down
19 changes: 4 additions & 15 deletions src/chain_actions/create_action.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::chain_actions::utils::now_date_time;
use crate::chain_actions::utils::add_current_time_path;
use crate::wire_element::WireElement;
use chrono::{DateTime, Datelike, Timelike, Utc};
use hdk::prelude::*;
use holo_hash::{AgentPubKey, EntryHashB64, HeaderHashB64};

Expand All @@ -9,6 +8,7 @@ use ::mockall::automock;

/// an enum passed into create_action to indicate whether the newly created entry is to be
/// linked off a path (like an anchor for entry types) or a supplied entry hash
#[derive(Debug, PartialEq, Clone)]
pub enum PathOrEntryHash {
Path(Path),
EntryHash(EntryHash),
Expand Down Expand Up @@ -52,7 +52,7 @@ impl CreateAction {
PathOrEntryHash::Path(path) => {
// link off entry path
path.ensure()?;
let path_hash = path.hash()?;
let path_hash = path.path_entry_hash()?;
create_link(path_hash, entry_hash.clone(), ())?;
}
PathOrEntryHash::EntryHash(base_entry_hash) => {
Expand All @@ -65,18 +65,7 @@ impl CreateAction {
None => (),
Some(base_component) => {
// create a time_path
let date: DateTime<Utc> = now_date_time()?;

let time_path = crate::datetime_queries::utils::hour_path_from_date(
base_component,
date.year(),
date.month(),
date.day(),
date.hour(),
);

time_path.ensure()?;
create_link(time_path.hash()?, entry_hash.clone(), ())?;
add_current_time_path(base_component, entry_hash.clone())?;
}
}
let time = sys_time()?; // this won't exactly match the timestamp stored in the element details
Expand Down
Loading

0 comments on commit 2836b12

Please sign in to comment.