2 # these metrics are how bogged down we are in to-do type items.
4 REPORT_FILE="$HOME/cloud/fred_stats/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_count()
11 local count=$(find "$dir" -type f -exec echo \"{}\" ';' 2>/dev/null | grep -v "\.svn" | grep -v "\.git"| grep -v "\.basket" | grep -v "\.version" | grep -v "\.keep" | wc -l | tr -d ' ')
12 if [ -z "$count" ]; then echo 0; else echo "$count"; fi
15 # calculates the size in kilobytes of all the note files in a hierarchy.
16 # this is just a raw statistic for how much content all those notes make up. since
17 # we have not separated out all the to-dos in some files (most notably the metaverse
18 # backlogs and to-do lists), it's good to also know what kind of girth the notes have.
19 function calculate_weight()
22 local weight=$(find "$dir" -type f -exec echo \"{}\" ';' 2>/dev/null | grep -v "\.svn" | grep -v "\.git"| grep -v "\.basket" | grep -v "\.version" | grep -v "\.keep" | xargs ls -al | awk '{ print $5 }' | paste -sd+ | bc 2>/dev/null)
23 if [ -z "$weight" ]; then echo 0; else echo "$weight"; fi
26 # calculate_complexity gets a very simple metric of how many directory components are
27 # present at the target location and below.
28 function calculate_complexity()
31 local complexity=$(find "$dir" -type d | wc -l)
32 if [ -z "$complexity" ]; then echo 0; else echo "$complexity"; fi
35 # produces a report line in our format.
36 function format_report_line()
38 local count="$1"; shift
39 local weight="$1"; shift
40 weight=$((weight / 1024))
41 local complexity="$1"; shift
42 echo "$count\t${complexity}\t\t${weight}\t\t$*\n"
45 # two parameters are needed: the directory to sum up and the label to use for it in the report.
46 # this will calculate the count and weight for a hierarchy of notes, and then produce a
47 # line of reporting for those.
48 function analyze_hierarchy_and_report()
51 local label="$1"; shift
53 # initial values are all zero.
58 if [ -d "$dir" ]; then
59 count=$(calculate_count "$dir")
60 total_overload=$(($count + $total_overload))
61 weight=$(calculate_weight "$dir")
62 total_weight=$(($total_weight + $weight))
63 complexity=$(calculate_complexity "$dir")
64 total_complexity=$(($total_complexity + $complexity))
66 full_report+=$(format_report_line "$count" "$weight" "$complexity" "$label")
69 # scans through items in the notes folder that begin with a pattern.
70 # each of those is treated as an aggregatable portion of the report.
71 # first parameter is the title in the report, second and so on are
72 # a list of directory patterns to scan and aggregate.
73 function analyze_by_dir_patterns()
75 local title="$1"; shift
78 local hier_complexity=0
80 if [ -d "$folder" ]; then
81 temp_count=$(calculate_count $folder)
82 hier_count=$(($hier_count + $temp_count))
83 temp_weight=$(calculate_weight $folder)
84 hier_weight=$(($hier_weight + $temp_weight))
85 temp_complexity=$(calculate_complexity $folder)
86 hier_complexity=$(($hier_complexity + $temp_complexity))
89 total_overload=$(($hier_count + $total_overload))
90 total_weight=$(($total_weight + $hier_weight))
91 total_complexity=$(($total_complexity + $hier_complexity))
92 full_report+=$(format_report_line "$hier_count" "$hier_weight" "$hier_complexity" "$title")
97 # reset these before we add anything...
101 # start out the report with a header.
104 current information overload consists of:\n\
107 full_report+="count\tcomplexity\tweight (kb)\tcategory\n\
108 ================================================================\n\
111 #hmmm: don't fail if the hierarchy doesn't exist.
113 # high priority stuff would be called urgent.
114 analyze_hierarchy_and_report ~/cloud/urgent "high priority (aieeee!)"
116 # notes are individual files of tasks, usually, although some are combined.
117 analyze_hierarchy_and_report ~/cloud/grunty_notes "grunty notes (externalities)"
119 # feisty notes are about feisty meow(r) concerns ltd codebase development.
120 analyze_hierarchy_and_report ~/cloud/feisty_notes "feisty meow notes (mondo coding)"
122 # home notes are a new top-level category; used to be under the grunty.
123 analyze_hierarchy_and_report ~/cloud/branch_road "hearth and home notes (branch road)"
125 # and then count up the things that we think will be cleaned soon, but one thing we have learned
126 # unsorted files haven't been categorized yet.
127 analyze_hierarchy_and_report ~/cloud/disordered "unsorted files"
129 # we now consider the backlog of things to read to be a relevant fact. this is going to hose
130 # up our weight accounting considerably.
131 analyze_hierarchy_and_report ~/cloud/reading "reading list (for a quiet afternoon)"
133 # scan all the items declared as active projects.
134 analyze_by_dir_patterns "active issues" ~/cloud/active*
136 # scan across all appropriately named project or research folders that live in the "cloud".
137 analyze_by_dir_patterns "running projects" ~/cloud/project* ~/cloud/research*
139 # look for our mad scientist style efforts.
140 analyze_by_dir_patterns "lab experiments" ~/cloud/experiment*
142 # snag any work related items for that category.
143 analyze_by_dir_patterns "jobby work tasks" ~/cloud/job*
145 # scan all the trivial project folders.
146 analyze_by_dir_patterns "trivialities" ~/cloud/trivia*
148 full_report+="================================================================\n\
150 full_report+="$(format_report_line "$total_overload" "$total_weight" "$total_complexity" "total overload")"
152 [gathered on $(date)]\n\n\
155 echo -e "$full_report" | tee -a "$REPORT_FILE"