-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3609 from the-turing-way/reporting-stats
Share script for book stats for reporting
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |