rename Issue and Comment timestamp creation_time
This is to make room for a second timestamp that records when the issue was marked Done.
This commit is contained in:
parent
e0d9d45a6a
commit
a40fa602eb
4 changed files with 49 additions and 35 deletions
|
|
@ -146,7 +146,7 @@ fn handle_command(
|
||||||
these_uuids.sort_by(|a_id, b_id| {
|
these_uuids.sort_by(|a_id, b_id| {
|
||||||
let a = issues.issues.get(*a_id).unwrap();
|
let a = issues.issues.get(*a_id).unwrap();
|
||||||
let b = issues.issues.get(*b_id).unwrap();
|
let b = issues.issues.get(*b_id).unwrap();
|
||||||
a.timestamp.cmp(&b.timestamp)
|
a.creation_time.cmp(&b.creation_time)
|
||||||
});
|
});
|
||||||
println!("{:?}:", state);
|
println!("{:?}:", state);
|
||||||
for uuid in these_uuids {
|
for uuid in these_uuids {
|
||||||
|
|
@ -191,8 +191,10 @@ fn handle_command(
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::New { description } => {
|
Commands::New { description } => {
|
||||||
let issues_database =
|
let issues_database = entomologist::database::make_issues_database(
|
||||||
entomologist::database::make_issues_database(issues_database_source, entomologist::database::IssuesDatabaseAccess::ReadWrite)?;
|
issues_database_source,
|
||||||
|
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||||
|
)?;
|
||||||
match entomologist::issue::Issue::new(&issues_database.dir, description) {
|
match entomologist::issue::Issue::new(&issues_database.dir, description) {
|
||||||
Err(entomologist::issue::IssueError::EmptyDescription) => {
|
Err(entomologist::issue::IssueError::EmptyDescription) => {
|
||||||
println!("no new issue created");
|
println!("no new issue created");
|
||||||
|
|
@ -209,8 +211,10 @@ fn handle_command(
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::Edit { uuid } => {
|
Commands::Edit { uuid } => {
|
||||||
let issues_database =
|
let issues_database = entomologist::database::make_issues_database(
|
||||||
entomologist::database::make_issues_database(issues_database_source, entomologist::database::IssuesDatabaseAccess::ReadWrite)?;
|
issues_database_source,
|
||||||
|
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||||
|
)?;
|
||||||
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||||
if let Some(issue) = issues.get_mut_issue(uuid) {
|
if let Some(issue) = issues.get_mut_issue(uuid) {
|
||||||
match issue.edit_description() {
|
match issue.edit_description() {
|
||||||
|
|
@ -249,7 +253,7 @@ fn handle_command(
|
||||||
Some(issue) => {
|
Some(issue) => {
|
||||||
println!("issue {}", issue_id);
|
println!("issue {}", issue_id);
|
||||||
println!("author: {}", issue.author);
|
println!("author: {}", issue.author);
|
||||||
println!("timestamp: {}", issue.timestamp);
|
println!("creation_time: {}", issue.creation_time);
|
||||||
println!("state: {:?}", issue.state);
|
println!("state: {:?}", issue.state);
|
||||||
if let Some(dependencies) = &issue.dependencies {
|
if let Some(dependencies) = &issue.dependencies {
|
||||||
println!("dependencies: {:?}", dependencies);
|
println!("dependencies: {:?}", dependencies);
|
||||||
|
|
@ -263,7 +267,7 @@ fn handle_command(
|
||||||
println!("");
|
println!("");
|
||||||
println!("comment: {}", comment.uuid);
|
println!("comment: {}", comment.uuid);
|
||||||
println!("author: {}", comment.author);
|
println!("author: {}", comment.author);
|
||||||
println!("timestamp: {}", comment.timestamp);
|
println!("creation_time: {}", comment.creation_time);
|
||||||
println!("");
|
println!("");
|
||||||
println!("{}", comment.description);
|
println!("{}", comment.description);
|
||||||
}
|
}
|
||||||
|
|
@ -279,8 +283,10 @@ fn handle_command(
|
||||||
new_state,
|
new_state,
|
||||||
} => match new_state {
|
} => match new_state {
|
||||||
Some(new_state) => {
|
Some(new_state) => {
|
||||||
let issues_database =
|
let issues_database = entomologist::database::make_issues_database(
|
||||||
entomologist::database::make_issues_database(issues_database_source, entomologist::database::IssuesDatabaseAccess::ReadWrite)?;
|
issues_database_source,
|
||||||
|
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||||
|
)?;
|
||||||
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||||
match issues.issues.get_mut(issue_id) {
|
match issues.issues.get_mut(issue_id) {
|
||||||
Some(issue) => {
|
Some(issue) => {
|
||||||
|
|
@ -312,8 +318,10 @@ fn handle_command(
|
||||||
issue_id,
|
issue_id,
|
||||||
description,
|
description,
|
||||||
} => {
|
} => {
|
||||||
let issues_database =
|
let issues_database = entomologist::database::make_issues_database(
|
||||||
entomologist::database::make_issues_database(issues_database_source, entomologist::database::IssuesDatabaseAccess::ReadWrite)?;
|
issues_database_source,
|
||||||
|
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||||
|
)?;
|
||||||
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||||
let Some(issue) = issues.get_mut_issue(issue_id) else {
|
let Some(issue) = issues.get_mut_issue(issue_id) else {
|
||||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||||
|
|
@ -338,9 +346,13 @@ fn handle_command(
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::Sync { remote } => {
|
Commands::Sync { remote } => {
|
||||||
if let entomologist::database::IssuesDatabaseSource::Branch(branch) = issues_database_source {
|
if let entomologist::database::IssuesDatabaseSource::Branch(branch) =
|
||||||
let issues_database =
|
issues_database_source
|
||||||
entomologist::database::make_issues_database(issues_database_source, entomologist::database::IssuesDatabaseAccess::ReadWrite)?;
|
{
|
||||||
|
let issues_database = entomologist::database::make_issues_database(
|
||||||
|
issues_database_source,
|
||||||
|
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||||
|
)?;
|
||||||
entomologist::git::sync(&issues_database.dir, remote, branch)?;
|
entomologist::git::sync(&issues_database.dir, remote, branch)?;
|
||||||
println!("synced {:?} with {:?}", branch, remote);
|
println!("synced {:?} with {:?}", branch, remote);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -440,7 +452,9 @@ fn main() -> anyhow::Result<()> {
|
||||||
// println!("{:?}", args);
|
// println!("{:?}", args);
|
||||||
|
|
||||||
let issues_database_source = match (&args.issues_dir, &args.issues_branch) {
|
let issues_database_source = match (&args.issues_dir, &args.issues_branch) {
|
||||||
(Some(dir), None) => entomologist::database::IssuesDatabaseSource::Dir(std::path::Path::new(dir)),
|
(Some(dir), None) => {
|
||||||
|
entomologist::database::IssuesDatabaseSource::Dir(std::path::Path::new(dir))
|
||||||
|
}
|
||||||
(None, Some(branch)) => entomologist::database::IssuesDatabaseSource::Branch(branch),
|
(None, Some(branch)) => entomologist::database::IssuesDatabaseSource::Branch(branch),
|
||||||
(None, None) => entomologist::database::IssuesDatabaseSource::Branch("entomologist-data"),
|
(None, None) => entomologist::database::IssuesDatabaseSource::Branch("entomologist-data"),
|
||||||
(Some(_), Some(_)) => {
|
(Some(_), Some(_)) => {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::io::{IsTerminal, Write};
|
||||||
pub struct Comment {
|
pub struct Comment {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
pub author: String,
|
pub author: String,
|
||||||
pub timestamp: chrono::DateTime<chrono::Local>,
|
pub creation_time: chrono::DateTime<chrono::Local>,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
|
||||||
/// This is the directory that the comment lives in. Only used
|
/// This is the directory that the comment lives in. Only used
|
||||||
|
|
@ -53,13 +53,13 @@ impl Comment {
|
||||||
}
|
}
|
||||||
|
|
||||||
let author = crate::git::git_log_oldest_author(comment_dir)?;
|
let author = crate::git::git_log_oldest_author(comment_dir)?;
|
||||||
let timestamp = crate::git::git_log_oldest_timestamp(comment_dir)?;
|
let creation_time = crate::git::git_log_oldest_timestamp(comment_dir)?;
|
||||||
let dir = std::path::PathBuf::from(comment_dir);
|
let dir = std::path::PathBuf::from(comment_dir);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
uuid: String::from(dir.file_name().unwrap().to_string_lossy()),
|
uuid: String::from(dir.file_name().unwrap().to_string_lossy()),
|
||||||
author,
|
author,
|
||||||
timestamp,
|
creation_time,
|
||||||
description: description.unwrap(),
|
description: description.unwrap(),
|
||||||
dir: std::path::PathBuf::from(comment_dir),
|
dir: std::path::PathBuf::from(comment_dir),
|
||||||
})
|
})
|
||||||
|
|
@ -84,7 +84,7 @@ impl Comment {
|
||||||
let mut comment = crate::comment::Comment {
|
let mut comment = crate::comment::Comment {
|
||||||
uuid,
|
uuid,
|
||||||
author: String::from(""), // this will be updated from git when we re-read this comment
|
author: String::from(""), // this will be updated from git when we re-read this comment
|
||||||
timestamp: chrono::Local::now(),
|
creation_time: chrono::Local::now(),
|
||||||
description: String::from(""), // this will be set immediately below
|
description: String::from(""), // this will be set immediately below
|
||||||
dir: dir.clone(),
|
dir: dir.clone(),
|
||||||
};
|
};
|
||||||
|
|
@ -204,7 +204,7 @@ mod tests {
|
||||||
let expected = Comment {
|
let expected = Comment {
|
||||||
uuid: String::from("9055dac36045fe36545bed7ae7b49347"),
|
uuid: String::from("9055dac36045fe36545bed7ae7b49347"),
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
||||||
|
|
|
||||||
14
src/issue.rs
14
src/issue.rs
|
|
@ -22,7 +22,7 @@ pub type IssueHandle = String;
|
||||||
pub struct Issue {
|
pub struct Issue {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub author: String,
|
pub author: String,
|
||||||
pub timestamp: chrono::DateTime<chrono::Local>,
|
pub creation_time: chrono::DateTime<chrono::Local>,
|
||||||
pub tags: Vec<String>,
|
pub tags: Vec<String>,
|
||||||
pub state: State,
|
pub state: State,
|
||||||
pub dependencies: Option<Vec<IssueHandle>>,
|
pub dependencies: Option<Vec<IssueHandle>>,
|
||||||
|
|
@ -159,12 +159,12 @@ impl Issue {
|
||||||
};
|
};
|
||||||
|
|
||||||
let author = crate::git::git_log_oldest_author(dir)?;
|
let author = crate::git::git_log_oldest_author(dir)?;
|
||||||
let timestamp = crate::git::git_log_oldest_timestamp(dir)?;
|
let creation_time = crate::git::git_log_oldest_timestamp(dir)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id,
|
id,
|
||||||
author,
|
author,
|
||||||
timestamp,
|
creation_time,
|
||||||
tags,
|
tags,
|
||||||
state: state,
|
state: state,
|
||||||
dependencies,
|
dependencies,
|
||||||
|
|
@ -185,7 +185,7 @@ impl Issue {
|
||||||
comments.push(comment);
|
comments.push(comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
comments.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));
|
comments.sort_by(|a, b| a.creation_time.cmp(&b.creation_time));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ impl Issue {
|
||||||
let mut issue = Self {
|
let mut issue = Self {
|
||||||
id: String::from(&issue_id),
|
id: String::from(&issue_id),
|
||||||
author: String::from(""),
|
author: String::from(""),
|
||||||
timestamp: chrono::Local::now(),
|
creation_time: chrono::Local::now(),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
state: State::New,
|
state: State::New,
|
||||||
dependencies: None,
|
dependencies: None,
|
||||||
|
|
@ -461,7 +461,7 @@ mod tests {
|
||||||
let expected = Issue {
|
let expected = Issue {
|
||||||
id: String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f"),
|
id: String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f"),
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::from([
|
tags: Vec::<String>::from([
|
||||||
|
|
@ -488,7 +488,7 @@ mod tests {
|
||||||
let expected = Issue {
|
let expected = Issue {
|
||||||
id: String::from("7792b063eef6d33e7da5dc1856750c149ba678c6"),
|
id: String::from("7792b063eef6d33e7da5dc1856750c149ba678c6"),
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ mod tests {
|
||||||
expected.add_issue(crate::issue::Issue {
|
expected.add_issue(crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
@ -109,7 +109,7 @@ mod tests {
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::from([
|
tags: Vec::<String>::from([
|
||||||
|
|
@ -141,7 +141,7 @@ mod tests {
|
||||||
expected.add_issue(crate::issue::Issue {
|
expected.add_issue(crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
@ -165,7 +165,7 @@ mod tests {
|
||||||
crate::comment::Comment {
|
crate::comment::Comment {
|
||||||
uuid: comment_uuid,
|
uuid: comment_uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local),
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local),
|
||||||
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
||||||
dir: std::path::PathBuf::from(comment_dir),
|
dir: std::path::PathBuf::from(comment_dir),
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ mod tests {
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
@ -202,7 +202,7 @@ mod tests {
|
||||||
expected.add_issue(crate::issue::Issue {
|
expected.add_issue(crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
@ -221,7 +221,7 @@ mod tests {
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
@ -241,7 +241,7 @@ mod tests {
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
||||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue