Compare commits
2 Commits
7f4ab49c91
...
914a57692f
Author | SHA1 | Date |
---|---|---|
Trey Blancher | 914a57692f | |
Trey Blancher | d86822c40e |
|
@ -57,8 +57,8 @@ if [[ -f ${DATE} ]]; then
|
||||||
subtotal=0
|
subtotal=0
|
||||||
for pattern in "${KEYS[@]}"; do
|
for pattern in "${KEYS[@]}"; do
|
||||||
#echo "pattern=${pattern}" >&2
|
#echo "pattern=${pattern}" >&2
|
||||||
$grep -- "\[${pattern}\]" ${DATE} | timetracker
|
$grep -- "\[${pattern}\]" ${DATE} | python timetracker.py
|
||||||
subtotal=$(bc <<< "scale=2; ${subtotal} + $($grep -- "\[${pattern}\]" ${DATE} | timetracker | $grep "Section" | $grep -Po '\d+\.\d+hrs' | tr -d '[hrs]')")
|
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}
|
printf "Subtotal: %3.2fhrs\n" ${subtotal}
|
||||||
echo
|
echo
|
||||||
if [[ "${WHOLE}x" == "x" ]]; then
|
if [[ "${WHOLE}x" == "x" ]]; then
|
||||||
|
|
|
@ -130,7 +130,7 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "do_process"
|
name = "doprocess"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"timetracker",
|
"timetracker",
|
||||||
"do_process",
|
"doprocess",
|
||||||
"chug",
|
"chug",
|
||||||
"timelogging"
|
"timelogging"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "do_process"
|
name = "doprocess"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
@ -6,6 +6,9 @@ use itertools::Itertools;
|
||||||
use timelogging::timetracking::{nearest, process_input_file, generate_individual_timecards};
|
use timelogging::timetracking::{nearest, process_input_file, generate_individual_timecards};
|
||||||
|
|
||||||
fn main() {
|
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)
|
// Process the file (stdin or file argument)
|
||||||
let input = env::args().nth(1);
|
let input = env::args().nth(1);
|
||||||
let mut reader: Box<dyn BufRead> = match input {
|
let mut reader: Box<dyn BufRead> = match input {
|
||||||
|
@ -24,7 +27,10 @@ fn main() {
|
||||||
let mut running_total: f64 = 0.0;
|
let mut running_total: f64 = 0.0;
|
||||||
for cat in categories {
|
for cat in categories {
|
||||||
let mut subtotal: f64 = 0.0;
|
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) {
|
for (act, duration) in ind.iter().sorted_by_key(|x| x.0) {
|
||||||
if ! catre.is_match(&act.to_string()) {
|
if ! catre.is_match(&act.to_string()) {
|
||||||
continue
|
continue
|
||||||
|
@ -49,3 +55,4 @@ fn main() {
|
||||||
|
|
||||||
println!("{}", format!("Grand total: {:.2}", gtoth));
|
println!("{}", format!("Grand total: {:.2}", gtoth));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue