Skip to content

Commit

Permalink
feat!: preparation for resuming activities from intermissions and oth…
Browse files Browse the repository at this point in the history
…er use cases (#43)

* fix: filter for activities to exclude intermissions from showing up in resume

Signed-off-by: simonsan <[email protected]>
(cherry picked from commit aca2b9d2b2bc4bfee8f4a64c7a1daf1ac7e55e2c)

* feat: introduce symbols to easier differentiate the ActivityKinds when being displayed to the user

Signed-off-by: simonsan <[email protected]>
(cherry picked from commit 57ebebf67ad49f4f27e2f230c78ef39bdba0b564)

* test: make tests pass again

Signed-off-by: simonsan <[email protected]>

* refactor: use btreemap for easier access via ids and use ids in config table headers

Signed-off-by: simonsan <[email protected]>

* refactor: rename to rwlock error to better reflect utilization

Signed-off-by: simonsan <[email protected]>

---------

Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan authored Feb 25, 2024
1 parent 7e6cb48 commit 7cde40e
Show file tree
Hide file tree
Showing 29 changed files with 2,105 additions and 837 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

35 changes: 10 additions & 25 deletions config/projects.pace.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,39 @@
# TODO: IDs are optional and can be generated with the `pace id`(??? is that sensible, or something else?) command.
# TODO: Add a `pace projects init` command to generate a new project configuration file.

[project]
id = "01HPY7F03JBVKSWDNTM2RSBXSJ"
[01HPY7F03JBVKSWDNTM2RSBXSJ]
name = "Pace Project"
description = "An example project managed with Pace."
root_tasks_file = "tasks.toml" # Path to the root tasks file
tasks-file = "./tasks.pace.toml" # Path to the root tasks file
filters = ["*pace*"] # Optional: Define default filters for your project

[defaults]
# Optional: Define a default category for your project
category = { id = "01HPY7F03K4AZMA0DVW3A1M0TG", name = "Uncategorized", description = "Uncategorized Content" }

[[categories]]
# Optional: Define categories for your project
id = "01HPY7F03K3JCWK5ZJJ02TT12G"
name = "Development"
description = "Development related tasks"
# Optional: Define subcategories for your category
# TODO: Add support for subcategories
subcategories = [
categories = [
{ id = "01HPY7F03K4AZMA0DVW3A1M0TG", name = "Uncategorized", description = "Uncategorized Content" },
{ id = "01HPY7F03K1H1A8A7S0K1ZCFX3", name = "Frontend", description = "Frontend Development" },
{ id = "01HPY7F03KSF8TXQQWZDF63DFD", name = "Backend", description = "Backend Development" },
{ id = "01HPY7F03KK3FGAJTHP2MBZA37", name = "Fullstack", description = "Fullstack Development" },
]

[[categories]]
# Optional: Define categories for your project
id = "01HPY7F03KS1YHKT86BXSMMEMX"
name = "Design"
description = "Design related tasks"

[[subprojects]]
[01HPY7F03K6TT2KKFEYVJT79ZB]
# Optional: Define subprojects or directories with their own tasks
id = "01HPY7F03K6TT2KKFEYVJT79ZB"
name = "Pace Subproject A"
description = ""
tasks_file = "subproject-a/tasks.toml"
tasks-file = "subproject-a/tasks.toml"
# Optional: Define default filters for your project
filters = [
"*pace*, *subproject-a",
]
parent-id = "01HPY7F03JBVKSWDNTM2RSBXSJ"

[[subprojects]]
[01HPY7F03KF7VE3K9E51P0H1TB]
# Optional: Define subprojects or directories with their own tasks
id = "01HPY7F03KF7VE3K9E51P0H1TB"
name = "Pace Subproject B"
description = ""
tasks_file = "subproject-b/tasks.toml"
tasks-file = "subproject-b/tasks.toml"
# Optional: Define default filters for your project
filters = [
"*pace*, *subproject-b",
]
parent-id = "01HPY7F03JBVKSWDNTM2RSBXSJ"
6 changes: 2 additions & 4 deletions config/tasks.pace.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# TODO: IDs are optional and can be generated with the `pace id`(??? is that sensible, or something else?) command.
# TODO: Add a `pace tasks init` command to generate a new project configuration file.

[[tasks]]
id = "01HPY7H596FT2R880SEKH7KN25"
[01HPY7H596FT2R880SEKH7KN25]
title = "Implement feature X"
created_at = "2024-02-04T12:34:56"
finished_at = "2024-02-05T13:34:56"
Expand All @@ -15,8 +14,7 @@ priority = "high"
status = "pending"
tags = ["feature", "X"]

[[tasks]]
id = "01HPY7F03JQ6SJF5C97H7G7E0E"
[01HPY7F03JQ6SJF5C97H7G7E0E]
title = "Fix bug Y"
created_at = "2024-02-06T12:34:56"
description = "Detailed description of bug Y to be fixed."
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ rayon = "1.8.1"
rusqlite = { version = "0.31.0", features = ["bundled", "chrono", "uuid"], optional = true }
serde = "1.0.197"
serde_derive = "1.0.197"
strum = "0.26.1"
strum = { version = "0.26.1", features = ["derive"] }
strum_macros = "0.26.1"
thiserror = "1.0.57"
toml = { version = "0.8.10", features = ["indexmap", "preserve_order"] }
Expand Down
24 changes: 24 additions & 0 deletions crates/core/src/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pub mod hold;
pub mod resume;

use getset::Getters;
use typed_builder::TypedBuilder;

use crate::{HoldOptions, PaceDateTime};

/// Options for ending an activity
#[derive(Debug, Clone, PartialEq, TypedBuilder, Eq, Hash, Default, Getters)]
#[getset(get = "pub")]
pub struct EndOptions {
/// The end time
#[builder(default, setter(into))]
end_time: PaceDateTime,
}

impl From<HoldOptions> for EndOptions {
fn from(hold_opts: HoldOptions) -> Self {
Self {
end_time: *hold_opts.begin_time(),
}
}
}
21 changes: 21 additions & 0 deletions crates/core/src/commands/hold.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use getset::Getters;
use typed_builder::TypedBuilder;

use crate::{IntermissionAction, PaceDateTime};

/// Options for holding an activity
#[derive(Debug, Clone, PartialEq, TypedBuilder, Eq, Hash, Default, Getters)]
#[getset(get = "pub")]
pub struct HoldOptions {
/// The action to take on the intermission
#[builder(default)]
action: IntermissionAction,

/// The start time of the intermission
#[builder(default, setter(into))]
begin_time: PaceDateTime,

/// The reason for holding the activity
#[builder(default, setter(into))]
reason: Option<String>,
}
1 change: 1 addition & 0 deletions crates/core/src/commands/resume.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

22 changes: 1 addition & 21 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ fn get_global_config_path() -> Option<PathBuf> {
#[cfg(test)]
mod tests {

use crate::{domain::project::ProjectConfig, domain::task::TaskList, error::TestResult};
use crate::error::TestResult;

use super::*;
use rstest::*;
Expand All @@ -495,24 +495,4 @@ mod tests {

Ok(())
}

#[rstest]
fn test_parse_project_file_passes(
#[files("../../config/projects.pace.toml")] config_path: PathBuf,
) -> TestResult<()> {
let toml_string = fs::read_to_string(config_path)?;
let _ = toml::from_str::<ProjectConfig>(&toml_string)?;

Ok(())
}

#[rstest]
fn test_parse_tasks_file_passes(
#[files("../../config/tasks.pace.toml")] config_path: PathBuf,
) -> TestResult<()> {
let toml_string = fs::read_to_string(config_path)?;
let _ = toml::from_str::<TaskList>(&toml_string)?;

Ok(())
}
}
Loading

0 comments on commit 7cde40e

Please sign in to comment.