# !/bin/bash # This script generates a CSV file that mimics Zoom's participant export CSV file # to be used for generating practice Powerbase import files. random_number() { local start="$1" local end="$2" local modulus=$(( "$end" - "$start" - 1 )) echo $(( $RANDOM % "$modulus" + "$start" )) } random_timestamp_last_month() { # 43,200 minutes in a month. local minutes_ago=$(random_number 1 43200) echo $(date -d "${minutes_ago} minutes ago" "+%s") } format_date() { local timestamp="$1" echo $(date -d "@$timestamp" "+%b %d, %Y %I:%M") } random_attended() { local num=$(( $RANDOM % 2 )) if [ "$num" -eq 1 ]; then echo "No" else echo "Yes" fi } start_timestamp=$(random_timestamp_last_month) report_generated=$(format_date $(( $start_timestamp + 86400 ))) webinar_id="$(random_number 100 999) $(random_number 1000 9999) $(random_number 1000 9999)" actual_duration_minutes=$(random_number 55 65) actual_duration_seconds=$(( "$actual_duration_minutes" * 60 )) actual_start_time=$(format_date "$start_timestamp") join_time="$actual_start_time" leave_time=$(format_date $(( "$start_timestamp" + "$actual_duration_seconds" )) ) register_time=$(format_date $(( "$start_timestamp" - 86400 )) ) star_wars_name=$(http 'http://names.drycodes.com/1?nameOptions=starwarsCharacters&combine=1' | grep '_' | tr -d '[]"' | sed "s/_/ /g" ) planet_name=$(http 'http://names.drycodes.com/1?nameOptions=planets&combine=1' | grep '"' | tr -d '[]"' | sed "s/_/ /" ) topic="Understanding labor policy, dialectics, $star_wars_name, and $planet_name" registered=10 cancelled=0 unique_visitors=10 total_users=10 max_concurrent_views=1 # Output the initial section. printf "Attendee Report,\n" printf 'Report Generated:,"%s"\n' "$report_generated" printf "Topic," printf "Webinar ID," printf "Actual Start Time," printf "Actual Duration (minutes)," printf "# Registered," printf "#Cancelled," printf "Unique Viewers," printf "Total Users," printf "Max Concurrent Views\n" printf '"%s",%s,"%s",%d,%d,%d,%d,%d,%d\n' \ "$topic" \ "$webinar_id" \ "$actual_start_time" \ "$actual_duration_minutes" \ "$registered" \ "$cancelled" \ "$unique_visitors" \ "$total_users" \ "$max_concurrent_views" \ printf "Host Details,\n" printf "Attended," printf "User Name," printf "Email," printf "Join Time," printf "Leave Time," printf "Time in Session (minutes)," printf "Country/Region Name\n" attended="Yes" user_name="Society for Praxis between Star Wars and the Movement of the Stars" email="stars@example.net" join_time="$actual_start_time" leave_time="$leave_time" time_in_session="$actual_duration_minutes" country="United State of America" printf '%s,%s,%s,"%s","%s",%s,%s\n' \ "$attended" \ "$user_name" \ "$email" \ "$join_time" \ "$leave_time" \ "$time_in_session" \ "$country" printf "Panelist Details,\n" printf "Attended," printf "User Name," printf "Email," printf "Join Time," printf "Leave Time," printf "Time in Session (minutes)," printf "Country/Region Name\n" girl_names=$(http 'http://names.drycodes.com/3?nameOptions=girl_names' | grep '_' | tr -d '[]"' ) for num in $(seq 1 3); do name=$(echo "$girl_names" | cut -d, -f${num}) first_name=$(echo "$name" | cut -d_ -f1) last_name=$(echo "$name" | cut -d_ -f2) attended="Yes" user_name="${first_name} ${last_name}" email="${first_name}.${last_name}.zoo@example.net" join_time="$actual_start_time" leave_time="$leave_time" time_in_session="$actual_duration_minutes" country="United State of America" printf '%s,%s,%s,"%s","%s",%s,%s\n' \ "$attended" \ "$user_name" \ "$email" \ "$join_time" \ "$leave_time" \ "$time_in_session" \ "$country" done printf "Attendee Details,\n" printf "Attended," printf "First Name," printf "Last Name," printf "Email," printf "Registration Time," printf "Approval Status," printf "Join Time," printf "Leave Time," printf "Time in Session (minutes)," printf "Country/Region Name," printf "Source Name\n" girl_names=$(http 'http://names.drycodes.com/10?nameOptions=girl_names' | grep '_' | tr -d '[]"' ) for num in $(seq 1 10); do name=$(echo "$girl_names" | cut -d, -f${num}) attended=$(random_attended) first_name=$(echo "$name" | cut -d_ -f1) last_name=$(echo "$name" | cut -d_ -f2) email="${first_name}.${last_name}.zoo@example.net" register_time="$register_time" approval_status="approved" join_time="$actual_start_time" leave_time="$leave_time" time_in_session="$actual_duration_minutes" country="United State of America" source_name="" printf '%s,%s,%s,%s,"%s",%s,"%s","%s",%d,%s,%s\n' \ "$attended" \ "$first_name" \ "$last_name" \ "$email" \ "$register_time" \ "$approval_status" \ "$join_time" \ "$leave_time" \ "$time_in_session" \ "$country" \ "$source_name" done