2 # these metrics are how bogged down we are in to-do type items.
4 REPORT_FILE="$HOME/cloud/overload_history.txt"
6 # given a path, this will find how many items are under it, ignoring svn and git files, plus
7 # other patterns we happen to notice are not useful.
8 function calculate_depth()
11 find "$dir" -type f -exec echo \"{}\" ';' | grep -v "\.svn" | grep -v "\.git"| grep -v "\.basket" | grep -v "\.version" | grep -v "\.keep" | wc -l | tr -d ' '
14 # calculates the size in kilobytes of all the note files in a hierarchy.
15 # this is just a raw statistic for how much content all those notes make up. since
16 # we have not separated out all the to-dos in some files (most notably the metaverse
17 # backlogs and to-do lists), it's good to also know what kind of girth the notes have.
18 function calculate_weight()
21 find "$dir" -type f -exec echo \"{}\" ';' | grep -v "\.svn" | grep -v "\.git"| grep -v "\.basket" | grep -v "\.version" | grep -v "\.keep" | xargs ls -al | awk '{ print $5 }' | paste -sd+ | bc
24 # produces a report line in our format.
25 function format_report_line()
27 local depth="$1"; shift
28 local weight="$1"; shift
29 weight=$((weight / 1024))
30 echo " $depth\t${weight}kb\t$*\n"
33 # two parameters are needed: the directory to sum up and the label to use for it in the report.
34 # this will calculate the depth and weight for a hierarchy of notes, and then produce a
35 # line of reporting for those.
36 function analyze_hierarchy_and_report()
39 local label="$1"; shift
40 local depth=$(calculate_depth "$dir")
41 total_overload=$(($depth + $total_overload))
42 local weight=$(calculate_weight "$dir")
43 total_weight=$(($total_weight + $weight))
44 full_report+=$(format_report_line "$depth" "$weight" "$label")
47 # scans through items in the notes folder that begin with a pattern.
48 # each of those is treated as an aggregable portion of the report.
49 # first parameter is the title in the report, second and so on are
50 # a list of directory patterns to scan and aggregate.
51 function analyze_by_dir_patterns()
53 local title="$1"; shift
57 temp_depth=$(calculate_depth $i)
58 hier_depth=$(($hier_depth + $temp_depth))
59 temp_weight=$(calculate_weight $i)
60 hier_weight=$(($hier_weight + $temp_weight))
62 total_overload=$(($hier_depth + $total_overload))
63 total_weight=$(($total_weight + $hier_weight))
64 full_report+=$(format_report_line "$hier_depth" "$hier_weight" "$title")
69 # reset these before we add anything...
73 # start out the report with a header.
76 Current information overload consists of:\n\
80 # notes are individual files of tasks, usually, although some are combined.
81 analyze_hierarchy_and_report ~/cloud/grunty_notes "grunty notes"
84 #hmmm: make an html todo scanning function from this.
85 # scan web documents for to-do lists. individual items are marked with <li>.
86 # we do this one a bit differently since we have different criteria for html to-do items.
87 html_item_depth=$(find ~/cloud/grunty_notes/ -type f -iname "*.html" -exec grep "<li" "{}" ';' | wc -l | tr -d ' ')
88 total_overload=$(($html_item_depth + $total_overload))
89 html_item_weight=$(find ~/cloud/grunty_notes/ -type f -iname "*.html" -exec grep "<li" "{}" ';' | wc -c | tr -d ' ')
90 total_weight=$(($total_weight + $html_item_weight))
91 full_report+="$(format_report_line "$html_item_depth" "$html_item_weight" "to-do notes in html")"
94 # scan all the items declared as active projects.
95 analyze_by_dir_patterns "active items" ~/cloud/*active*
97 # scan across all appropriately named project or research folders that live in the "cloud".
98 analyze_by_dir_patterns "project files" ~/cloud/*project* ~/cloud/*research*
100 # source examples need to be sucked into other places, other codebases. they are not
101 # supposed to pile up here.
102 analyze_hierarchy_and_report ~/cloud/example_source "source examples"
104 # also snag the files labelled as trivia, since they're still to-dos...
105 analyze_by_dir_patterns "trivial notes" ~/cloud/*trivia*
107 # and then count up the things that we think will be cleaned soon, but one thing we have learned
108 # unsorted files haven't been categorized yet.
109 analyze_hierarchy_and_report ~/cloud/unsorted "unsorted files"
111 # we now consider the backlog of things to read to be a relevant fact. this is going to hose
112 # up our weight accounting considerably.
113 analyze_hierarchy_and_report ~/cloud/reading "reading list"
116 =====================================\n\
118 full_report+="$(format_report_line "$total_overload" "$total_weight" "Total Overload")"
120 [gathered on $(date)]\n\n\
123 echo -e "$full_report" | tee -a "$REPORT_FILE"