Skip to content

Commit

Permalink
consistent naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjani committed Dec 31, 2023
1 parent 1836ffb commit d79a8a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub static DEFAULT_NESTED_TAG: &str = "/";
pub static DEFAULT_ANNOTATION_TEMPLATE: &str = r#"
### {{id}}
Group: {{group_id}} ({{group_name}})
Group: {{group}} ({{group_name}})
Created: {{date_format "%c" created}}
Tags: {{#each tags}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}
Expand Down Expand Up @@ -53,8 +53,8 @@ pub enum OrderBy {
Empty,
Created,
Updated,
GroupID,
Group,
GroupName,
}

impl fmt::Display for OrderBy {
Expand All @@ -68,8 +68,8 @@ impl fmt::Display for OrderBy {
OrderBy::Empty => write!(f, "empty"),
OrderBy::Created => write!(f, "created"),
OrderBy::Updated => write!(f, "updated"),
OrderBy::GroupID => write!(f, "group_id"),
OrderBy::Group => write!(f, "group"),
OrderBy::GroupName => write!(f, "group_name"),
}
}
}
Expand Down Expand Up @@ -418,8 +418,8 @@ file_extension = '{}'
OrderBy::BaseURI,
OrderBy::Title,
OrderBy::ID,
OrderBy::GroupID,
OrderBy::Group,
OrderBy::GroupName,
];
let order = Self::get_order_bys(selections)?;
if order.is_empty() {
Expand Down Expand Up @@ -461,8 +461,8 @@ file_extension = '{}'
OrderBy::Title,
OrderBy::Created,
OrderBy::Updated,
OrderBy::GroupID,
OrderBy::Group,
OrderBy::GroupName,
];
let order = Self::get_order_bys(selections)?;

Expand Down
13 changes: 5 additions & 8 deletions src/gooseberry/knowledge_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub struct AnnotationTemplate {
pub highlight: Vec<String>,
pub display_name: Option<String>,
pub group_name: String,
pub group_id: String,
}

pub fn replace_spaces(astring: &str) -> String {
Expand Down Expand Up @@ -77,7 +76,6 @@ impl AnnotationTemplate {
.get(&annotation.group)
.unwrap_or(&annotation.group)
.to_owned();
let group_id = annotation.group.to_owned();
AnnotationTemplate {
annotation,
base_uri,
Expand All @@ -86,7 +84,6 @@ impl AnnotationTemplate {
highlight,
display_name,
group_name,
group_id,
}
}
}
Expand Down Expand Up @@ -231,15 +228,15 @@ fn group_annotations_by_order(
.push(annotation);
}
}
OrderBy::GroupID => {
OrderBy::Group => {
for annotation in annotations {
order_to_annotations
.entry(annotation.group_id.to_string())
.entry(annotation.annotation.group.to_string())
.or_insert_with(Vec::new)
.push(annotation);
}
}
OrderBy::Group => {
OrderBy::GroupName => {
for annotation in annotations {
order_to_annotations
.entry(annotation.group_name.to_string())
Expand Down Expand Up @@ -270,8 +267,8 @@ fn sort_annotations(sort: &[OrderBy], annotations: &mut [AnnotationTemplate]) {
.cmp(&format!("{}", b.annotation.created.format("%+"))),
OrderBy::Updated => format!("{}", a.annotation.updated.format("%+"))
.cmp(&format!("{}", b.annotation.updated.format("%+"))),
OrderBy::GroupID => a.group_id.cmp(&b.group_id),
OrderBy::Group => a.group_name.cmp(&b.group_name),
OrderBy::Group => a.annotation.group.cmp(&b.annotation.group),
OrderBy::GroupName => a.group_name.cmp(&b.group_name),
OrderBy::Empty => panic!("Shouldn't happen"),
})
})
Expand Down

0 comments on commit d79a8a9

Please sign in to comment.