5e0fc22f633f81b9c1adfb29ef99624f7cde588e
[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 REPORT_FILE="$HOME/cloud/fred_stats/overload_history.txt"
5
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()
9 {
10   local dir="$1"; shift
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
13 }
14
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()
20 {
21   local dir="$1"; shift
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
24 }
25
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()
29 {
30   local dir="$1"; shift
31   local complexity=$(find "$dir" -type d | wc -l)
32   if [ -z "$complexity" ]; then echo 0; else echo "$complexity"; fi
33 }
34
35 # produces a report line in our format.
36 function format_report_line()
37 {
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"
43 }
44
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()
49 {
50   local dir="$1"; shift
51   local label="$1"; shift
52
53   # initial values are all zero.
54   local count=0
55   local weight=0
56   local complexity=0
57
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))
65   fi
66   full_report+=$(format_report_line "$count" "$weight" "$complexity" "$label")
67 }
68
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()
74 {
75   local title="$1"; shift
76   local hier_count=0
77   local hier_weight=0
78   local hier_complexity=0
79   for folder in $@; do
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))
87     fi
88   done
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")
93 }
94
95 ##############
96
97 # reset these before we add anything...
98 total_overload=0
99 total_weight=0
100
101 # start out the report with a header.
102 full_report="\
103 \n\
104 current information overload consists of:\n\
105 \n\
106 "
107 full_report+="count\tcomplexity\tweight (kb)\tcategory\n\
108 ================================================================\n\
109 "
110
111 #hmmm: don't fail if the hierarchy doesn't exist.
112
113 # high priority stuff would be called urgent.
114 analyze_hierarchy_and_report ~/cloud/urgent "high priority (aieeee!)"
115
116 # notes are individual files of tasks, usually, although some are combined.
117 analyze_hierarchy_and_report ~/cloud/grunty_notes "grunty notes (externalities)"
118
119 # web site development tasks.
120 analyze_hierarchy_and_report ~/cloud/webular "web design (ideas and tasks)"
121
122 # feisty notes are about feisty meow(r) concerns ltd codebase development.
123 analyze_hierarchy_and_report ~/cloud/feisty_notes "feisty meow notes (mondo coding)"
124
125 # metaverse notes are about our ongoing simulator development and LSL scripting.
126 analyze_hierarchy_and_report ~/cloud/metaverse "metaverse in cyberspace design and scripting"
127
128 # home notes are a new top-level category; used to be under the grunty.
129 analyze_hierarchy_and_report ~/cloud/branch_road "hearth and home notes (branch road)"
130
131 # and then count up the things that we think will be cleaned soon, but one thing we have learned
132 # unsorted files haven't been categorized yet.
133 analyze_hierarchy_and_report ~/cloud/disordered "disordered and maybe deranged files"
134
135 # we now consider the backlog of things to read to be a relevant fact.  this is going to hose
136 # up our weight accounting considerably.
137 analyze_hierarchy_and_report ~/cloud/reading "reading list (for a quiet afternoon)"
138
139 ####
140
141 # vocation is a prefix for anything i consider part of my life's work.
142 analyze_by_dir_patterns "life's work and other oddities" ~/cloud/vocation*
143
144 # scan all the items declared as active projects.
145 analyze_by_dir_patterns "active issues" ~/cloud/active*
146
147 # scan across all appropriately named project or research folders that live in the "cloud".
148 analyze_by_dir_patterns "running projects" ~/cloud/project* ~/cloud/research*
149
150 # look for our mad scientist style efforts.
151 analyze_by_dir_patterns "lab experiments" ~/cloud/experiment*
152
153 # snag any work related items for that category.
154 analyze_by_dir_patterns "jobby work tasks" ~/cloud/job* 
155
156 # scan all the trivial project folders.
157 analyze_by_dir_patterns "trivialities and back burner items" ~/cloud/trivia* ~/cloud/backburn*
158
159 full_report+="================================================================\n\
160 "
161 full_report+="$(format_report_line "$total_overload" "$total_weight" "$total_complexity" "total overload")"
162 full_report+="\n\
163 [gathered on $(date)]\n\n\
164 ##############"
165
166 echo -e "$full_report" | tee -a "$REPORT_FILE"
167