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