Compare commits

...

2 Commits

Author SHA1 Message Date
Trey Blancher 914a57692f Refactored doprocess 2022-11-11 12:38:54 -05:00
Trey Blancher d86822c40e Updated to use old timetracker.py (slightly different output format than Rust program) 2022-11-11 12:36:14 -05:00
5 changed files with 13 additions and 6 deletions

View File

@ -57,8 +57,8 @@ if [[ -f ${DATE} ]]; then
subtotal=0
for pattern in "${KEYS[@]}"; do
#echo "pattern=${pattern}" >&2
$grep -- "\[${pattern}\]" ${DATE} | timetracker
subtotal=$(bc <<< "scale=2; ${subtotal} + $($grep -- "\[${pattern}\]" ${DATE} | timetracker | $grep "Section" | $grep -Po '\d+\.\d+hrs' | tr -d '[hrs]')")
$grep -- "\[${pattern}\]" ${DATE} | python timetracker.py
subtotal=$(bc <<< "scale=2; ${subtotal} + $($grep -- "\[${pattern}\]" ${DATE} | python timetracker.py | $grep "Section" | $grep -Po '\d+\.\d+hrs' | tr -d '[hrs]')")
printf "Subtotal: %3.2fhrs\n" ${subtotal}
echo
if [[ "${WHOLE}x" == "x" ]]; then

View File

@ -130,7 +130,7 @@ dependencies = [
]
[[package]]
name = "do_process"
name = "doprocess"
version = "0.1.0"
dependencies = [
"itertools",

View File

@ -2,7 +2,7 @@
members = [
"timetracker",
"do_process",
"doprocess",
"chug",
"timelogging"
]

View File

@ -1,5 +1,5 @@
[package]
name = "do_process"
name = "doprocess"
version = "0.1.0"
edition = "2021"

View File

@ -6,6 +6,9 @@ use itertools::Itertools;
use timelogging::timetracking::{nearest, process_input_file, generate_individual_timecards};
fn main() {
// set up a regex for escaping regex characters
let cat_esc = Regex::new(r"(?P<char>[-*^$+?])").unwrap();
// Process the file (stdin or file argument)
let input = env::args().nth(1);
let mut reader: Box<dyn BufRead> = match input {
@ -24,7 +27,10 @@ fn main() {
let mut running_total: f64 = 0.0;
for cat in categories {
let mut subtotal: f64 = 0.0;
let catre = Regex::new(&format!(r"\[{}\]\s+.*\s*$", cat).to_string()).unwrap();
let catre = Regex::new(&format!(r"\[{}\]\s+.*\s*$",
cat_esc.replace_all(&cat, r"\$char".to_string()))
.to_string())
.unwrap();
for (act, duration) in ind.iter().sorted_by_key(|x| x.0) {
if ! catre.is_match(&act.to_string()) {
continue
@ -49,3 +55,4 @@ fn main() {
println!("{}", format!("Grand total: {:.2}", gtoth));
}