updated count
[feisty_meow.git] / scripts / notes / 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/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_depth()
9 {
10   local dir="$1"; shift
11   depth=$(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 "$depth" ]; then echo 0; else echo "$depth"; 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   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 # produces a report line in our format.
27 function format_report_line()
28 {
29   local depth="$1"; shift
30   local weight="$1"; shift
31   weight=$((weight / 1024))
32   echo "  $depth\t${weight}kb\t$*\n"
33 }
34
35 # two parameters are needed: the directory to sum up and the label to use for it in the report.
36 # this will calculate the depth and weight for a hierarchy of notes, and then produce a
37 # line of reporting for those.
38 function analyze_hierarchy_and_report()
39 {
40   local dir="$1"; shift
41   local label="$1"; shift
42   local depth=$(calculate_depth "$dir")
43   total_overload=$(($depth + $total_overload))
44   local weight=$(calculate_weight "$dir")
45   total_weight=$(($total_weight + $weight))
46   full_report+=$(format_report_line "$depth" "$weight" "$label")
47 }
48
49 # scans through items in the notes folder that begin with a pattern.
50 # each of those is treated as an aggregable portion of the report.
51 # first parameter is the title in the report, second and so on are
52 # a list of directory patterns to scan and aggregate.
53 function analyze_by_dir_patterns()
54 {
55   local title="$1"; shift
56   local hier_depth=0
57   local hier_weight=0
58   for i in $@; do
59     temp_depth=$(calculate_depth $i)
60     hier_depth=$(($hier_depth + $temp_depth))
61     temp_weight=$(calculate_weight $i)
62     hier_weight=$(($hier_weight + $temp_weight))
63   done
64   total_overload=$(($hier_depth + $total_overload))
65   total_weight=$(($total_weight + $hier_weight))
66   full_report+=$(format_report_line "$hier_depth" "$hier_weight" "$title")
67 }
68
69 ##############
70
71 # reset these before we add anything...
72 total_overload=0
73 total_weight=0
74
75 # start out the report with a header.
76 full_report="\
77 \n\
78 Current information overload consists of:\n\
79 \n\
80 "
81
82 # notes are individual files of tasks, usually, although some are combined.
83 analyze_hierarchy_and_report ~/cloud/grunty_notes "grunty notes"
84
85 # feisty notes are about feisty meow(r) concerns ltd codebase development.
86 analyze_hierarchy_and_report ~/cloud/feisty_notes "feisty meow notes"
87
88 ####
89 #hmmm: make an html todo scanning function from this.
90 # scan web documents for to-do lists.  individual items are marked with <li>.
91 # we do this one a bit differently since we have different criteria for html to-do items.
92 #html_item_depth=$(find ~/cloud/grunty_notes/ -type f -iname "*.html" -exec grep "<li" "{}" ';' | wc -l | tr -d ' ')
93 #total_overload=$(($html_item_depth + $total_overload))
94 #html_item_weight=$(find ~/cloud/grunty_notes/ -type f -iname "*.html" -exec grep "<li" "{}" ';' | wc -c | tr -d ' ')
95 #total_weight=$(($total_weight + $html_item_weight))
96 #full_report+="$(format_report_line "$html_item_depth" "$html_item_weight" "to-do notes in html")"
97 ####
98
99 # scan all the items declared as active projects.
100 analyze_by_dir_patterns "active items" ~/cloud/*active*
101
102 # scan across all appropriately named project or research folders that live in the "cloud".
103 analyze_by_dir_patterns "project files" ~/cloud/*project* ~/cloud/*research*
104
105 # scan all the trivial project folders.
106 analyze_by_dir_patterns "trivial items" ~/cloud/*trivia*
107
108 # source examples need to be sucked into other places, other codebases.  they are not
109 # supposed to pile up here.
110 analyze_hierarchy_and_report ~/cloud/example_source "source examples"
111
112 # and then count up the things that we think will be cleaned soon, but one thing we have learned
113 # unsorted files haven't been categorized yet.
114 analyze_hierarchy_and_report ~/cloud/unsorted "unsorted files"
115
116 # we now consider the backlog of things to read to be a relevant fact.  this is going to hose
117 # up our weight accounting considerably.
118 analyze_hierarchy_and_report ~/cloud/reading "reading list"
119
120 full_report+="\n\
121   =====================================\n\
122 "
123 full_report+="$(format_report_line "$total_overload" "$total_weight" "Total Overload")"
124 full_report+="\n\
125 [gathered on $(date)]\n\n\
126 ##############"
127
128 echo -e "$full_report" | tee -a "$REPORT_FILE"
129