Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share script for book stats for reporting #3609

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading