Skip to content

Commit

Permalink
Merge pull request #3609 from the-turing-way/reporting-stats
Browse files Browse the repository at this point in the history
Share script for book stats for reporting
  • Loading branch information
malvikasharan committed Apr 16, 2024
2 parents 35b2dc7 + c161dea commit 11fb607
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions project_management/quarterly_reports/book-stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Book stats for chapters and subchapters, generated on: 2024-04-15 22:21:35.3N
guide name; number of chapters; number of subchapters
reproducible-research; 16; 115
project-design; 10; 44
communication; 14; 56
collaboration; 18; 62
ethical-research; 11; 27
community-handbook; 16; 68
all guides; 85; 372
39 changes: 39 additions & 0 deletions project_management/quarterly_reports/count-chapters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# run this script locally in the 'quarterly report' folder
# Indicate the date and time for last stat generation

current_time=$(date +"%Y-%m-%d %H:%M:%S.%3N")
echo "#Book stats for chapters and subchapters, \
generated on: $current_time" > book-stats.md

# add table header
echo "guide name; number of chapters; number of subchapters" >> book-stats.md
echo "guide name; number of chapters; number of subchapters"

path="../../book/website/"
# Sum up chapters and subchapter
total_chapters=0
total_subchapters=0

# list of guides
guide_list=(reproducible-research project-design \
communication collaboration ethical-research \
community-handbook)

# loop over guide list
for guide in "${guide_list[@]}";do
# count chapters in each guide
chapters=$(find "${path}${guide}" -maxdepth 1 -type f | cut -d/ -f2 | sort | wc -l | awk '{print $1 - 1}')
# count subchapters in each guide
subchapters=$(find "${path}${guide}" -type f | cut -d/ -f2 | sort | wc -l| awk '{print $1 - 1}')

echo "${guide}; $chapters; $subchapters"
echo "${guide}; $chapters; $subchapters" >> book-stats.md

total_chapters=$((total_chapters + $chapters))
total_subchapters=$((total_subchapters + $subchapters))
done

# Sum all chapters and subchapters from all guides
echo "\nall guides; $total_chapters; $total_subchapters"
echo "all guides; $total_chapters; $total_subchapters" >> book-stats.md

0 comments on commit 11fb607

Please sign in to comment.