Skip to content

Commit

Permalink
Last written days
Browse files Browse the repository at this point in the history
  • Loading branch information
jerbly committed Jan 5, 2024
1 parent 86df842 commit a83dbbf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "honey-health"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
authors = ["Jeremy Blythe <[email protected]>"]

Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ git clone https://github.com/jerbly/honey-health.git
$ cd honey-health
$ cargo build --release
$ ./target/release/honey-health --version
0.2.0
0.3.0
```

## Usage
Expand All @@ -59,11 +59,12 @@ Honey Health
Usage: honey-health [OPTIONS] --model <MODEL>...
Options:
-m, --model <MODEL>... Model paths
-d, --dataset [<DATASET>...] Datasets
-o, --output <OUTPUT> Output file path [default: hh_report.csv]
-h, --help Print help (see more with '--help')
-V, --version Print version
-m, --model <MODEL>... Model paths
-d, --dataset [<DATASET>...] Datasets
-o, --output <OUTPUT> Output file path [default: hh_report.csv]
-l, --last-written-days <LAST_WRITTEN_DAYS> Max last written days [default: 30]
-h, --help Print help (see more with '--help')
-V, --version Print version
```

You must provide `HONEYCOMB_API_KEY` as an environment variable or in a `.env` file. This api key must have access to read datasets and columns.
Expand Down
20 changes: 11 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl ColumnUsageMap {
fn new(
root_dirs: &[String],
include_datasets: Option<HashSet<String>>,
max_last_written_days: usize,
) -> anyhow::Result<Self> {
let sc = SemanticConventions::new(root_dirs)?;

Expand All @@ -103,7 +104,7 @@ impl ColumnUsageMap {
.list_all_datasets()?
.iter()
.filter_map(|d| {
if (now - d.last_written_at).num_days() < 60 {
if (now - d.last_written_at).num_days() < max_last_written_days as i64 {
if inc_datasets.is_empty() || inc_datasets.contains(&d.slug) {
Some(d.slug.clone())
} else {
Expand All @@ -124,7 +125,7 @@ impl ColumnUsageMap {
let mut dataset_health = DatasetHealth::new();
for column in columns {
let duration = now - column.last_written;
if duration.num_days() < 60 {
if duration.num_days() < max_last_written_days as i64 {
let health: Suggestion;
if let Some(cu) = cm.map.get_mut(&column.key_name) {
cu.datasets[dataset_num] = true;
Expand Down Expand Up @@ -290,6 +291,13 @@ struct Args {
/// used when more than one dataset is included.
#[arg(short, long, default_value_t = String::from("hh_report.csv"))]
output: String,

/// Max last written days
///
/// The maximum number of days since a dataset was last written to. This
/// defaults to 30 days.
#[arg(short, long, default_value_t = 30)]
last_written_days: usize,
}

fn main() -> anyhow::Result<()> {
Expand All @@ -309,7 +317,7 @@ fn main() -> anyhow::Result<()> {
);
}
let include_datasets = args.dataset.map(HashSet::from_iter);
let cm = ColumnUsageMap::new(&root_dirs, include_datasets)?;
let cm = ColumnUsageMap::new(&root_dirs, include_datasets, args.last_written_days)?;
if cm.datasets.is_empty() {
println!("No datasets found");
return Ok(());
Expand All @@ -321,9 +329,3 @@ fn main() -> anyhow::Result<()> {
cm.print_dataset_report();
Ok(())
}

// IDEAS
// Store the namespace as a trie for searching
// Provide command line to explore the trie to help find suitable namespaces and attribute names
// Search for attributes with natural language
// Generate a web page with a tree explorer across your semantic conventions
1 change: 0 additions & 1 deletion src/semconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ impl SemanticConventions {
}

// Break up the namespace a.b.c into a, a.b, a.b.c and store them in the set
// TODO store this as a trie
fn insert_prefixes(&mut self, input: &str) {
let mut prefix = String::new();
for c in input.chars() {
Expand Down

0 comments on commit a83dbbf

Please sign in to comment.