8eff1bfd821c4c7a095ffe4d27852c8403d0cf64
[feisty_meow.git] / scripts / agenda / info_overload_report.sh
1
2 # these metrics are how bogged down we are in to-do type items.
3
4 # logged historical file where we append our latest report.
5 REPORT_FILE="$HOME/cloud/stats/overload_history.txt"
6
7 # given a path, this will find how many items are under it, ignoring svn and git files, plus
8 # other patterns we happen to notice are not useful.
9 function calculate_count()
10 {
11   local dir="$1"; shift
12   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 ' ')
13   if [ -z "$count" ]; then echo 0; else echo "$count"; fi
14 }
15
16 # calculates the size in kilobytes of all the note files in a hierarchy.
17 # this is just a raw statistic for how much content all those notes make up.  since
18 # we have not separated out all the to-dos in some files (most notably the metaverse
19 # backlogs and to-do lists), it's good to also know what kind of girth the notes have.
20 function calculate_weight()
21 {
22   local dir="$1"; shift
23   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)
24   if [ -z "$weight" ]; then echo 0; else echo "$weight"; fi
25 }
26
27 # calculate_complexity gets a very simple metric of how many directory components are
28 # present at the target location and below.
29 function calculate_complexity()
30 {
31   local dir="$1"; shift
32   local complexity=$(find "$dir" -type d | wc -l)
33   if [ -z "$complexity" ]; then echo 0; else echo "$complexity"; fi
34 }
35
36 # produces a report line in our format.
37 function format_report_line()
38 {
39   local count="$1"; shift
40   local weight="$1"; shift
41   weight=$((weight / 1024))
42   local complexity="$1"; shift
43   echo "$count\t${complexity}\t\t${weight}\t\t$*\n"
44 }
45
46 # two parameters are needed: the directory to sum up and the label to use for it in the report.
47 # this will calculate the count and weight for a hierarchy of notes, and then produce a
48 # line of reporting for those.
49 function analyze_hierarchy_and_report()
50 {
51   local dir="$1"; shift
52   local label="$1"; shift
53
54   # initial values are all zero.
55   local count=0
56   local weight=0
57   local complexity=0
58
59   if [ -d "$dir" ]; then
60     count=$(calculate_count "$dir")
61     total_overload=$(($count + $total_overload))
62     weight=$(calculate_weight "$dir")
63     total_weight=$(($total_weight + $weight))
64     complexity=$(calculate_complexity "$dir")
65     total_complexity=$(($total_complexity + $complexity))
66   fi
67   full_report+=$(format_report_line "$count" "$weight" "$complexity" "$label")
68 }
69
70 # scans through items in the notes folder that begin with a pattern.
71 # each of those is treated as an aggregatable portion of the report.
72 # first parameter is the title in the report, second and so on are
73 # a list of directory patterns to scan and aggregate.
74 function analyze_by_dir_patterns()
75 {
76   local title="$1"; shift
77   local hier_count=0
78   local hier_weight=0
79   local hier_complexity=0
80   for folder in $@; do
81     if [ -d "$folder" ]; then
82       temp_count=$(calculate_count $folder)
83       hier_count=$(($hier_count + $temp_count))
84       temp_weight=$(calculate_weight $folder)
85       hier_weight=$(($hier_weight + $temp_weight))
86       temp_complexity=$(calculate_complexity $folder)
87       hier_complexity=$(($hier_complexity + $temp_complexity))
88     fi
89   done
90   total_overload=$(($hier_count + $total_overload))
91   total_weight=$(($total_weight + $hier_weight))
92   total_complexity=$(($total_complexity + $hier_complexity))
93   full_report+=$(format_report_line "$hier_count" "$hier_weight" "$hier_complexity" "$title")
94 }
95
96 ##############
97
98 # reset these before we add anything...
99 total_overload=0
100 total_weight=0
101
102 # start out the report with a header.
103 full_report="\
104 \n\
105 current information overload consists of:\n\
106 \n\
107 "
108 full_report+="count\tcomplexity\tweight (kb)\tcategory\n\
109 ================================================================\n\
110 "
111
112 #hmmm: don't fail if the hierarchy doesn't exist.
113
114 # high priority stuff would be called urgent.
115 analyze_hierarchy_and_report ~/cloud/urgent "high priority (aieeee!)"
116
117 # notes are individual files of tasks, usually, although some are combined.
118 analyze_hierarchy_and_report ~/cloud/grunty* "grunty (external facing) notes"
119
120 # web site development tasks.
121 analyze_hierarchy_and_report ~/cloud/webular "web design (ideas and tasks)"
122
123 # feisty notes are about feisty meow(r) concerns ltd codebase development.
124 analyze_hierarchy_and_report ~/cloud/feisty_notes "feisty meow notes (mondo coding)"
125
126 # metaverse notes are about our ongoing simulator development and LSL scripting.
127 analyze_hierarchy_and_report ~/cloud/metaverse "metaverse in cyberspace design and scripting"
128
129 # home notes are a new top-level category; used to be under the grunty.
130 analyze_hierarchy_and_report ~/cloud/branch_road "hearth and home notes (branch road)"
131
132 # and then count up the things that we think will be cleaned soon, but one thing we have learned
133 # unsorted files haven't been categorized yet.
134 analyze_hierarchy_and_report ~/cloud/disordered "disordered and maybe deranged files"
135
136 # we now consider the backlog of things to read to be a relevant fact.  this is going to hose
137 # up our weight accounting considerably.
138 analyze_hierarchy_and_report ~/cloud/reading "reading list (for a quiet afternoon)"
139
140 ####
141
142 # vocation is a prefix for anything i consider part of my life's work.
143 analyze_by_dir_patterns "life's work and other oddities" ~/cloud/vocation*
144
145 # scan all the items declared as active projects.
146 analyze_by_dir_patterns "active issues" ~/cloud/active*
147
148 # rub alongside all the travel notes to see if any have interesting burrs.
149 analyze_by_dir_patterns "travel plans" ~/cloud/walkabout*
150
151 # scan across all appropriately named project or research folders that live in the "cloud".
152 analyze_by_dir_patterns "running projects" ~/cloud/project* ~/cloud/research*
153
154 # look for our mad scientist style efforts.
155 analyze_by_dir_patterns "lab experiments" ~/cloud/experiment*
156
157 # snag any work related items for that category.
158 analyze_by_dir_patterns "jobby work tasks" ~/cloud/job* 
159
160 # scan all the trivial project folders.
161 analyze_by_dir_patterns "trivialities and back burner items" ~/cloud/trivia* ~/cloud/backburn*
162
163 full_report+="================================================================\n\
164 "
165 full_report+="$(format_report_line "$total_overload" "$total_weight" "$total_complexity" "total overload")"
166 full_report+="\n\
167 [gathered on $(date)]\n\n\
168 ##############"
169
170 echo -e "$full_report" | tee -a "$REPORT_FILE"
171