diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index 147d7be..9d27477 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -893,6 +893,131 @@ grep_wordpress_path() { [ -d "$path" ] && [ -f "$path/$WP_CRON_FILENAME" ] } +# ADVANCED FEATURE: Report Generation (OPT-17) +# Generates structured reports in multiple formats for integration with monitoring systems +# Supports JSON, CSV, and text formats for different use cases +declare -g REPORT_FORMAT="text" # text, json, csv +declare -g REPORT_FILE="" +declare -gA REPORT_DATA + +# Initialize report data collection +report_init() { + REPORT_DATA[total_sites]=0 + REPORT_DATA[total_converted]=0 + REPORT_DATA[total_failed]=0 + REPORT_DATA[total_skipped]=0 + REPORT_DATA[start_time]=$(date +%s) +} + +# Add operation result to report +report_add_result() { + local site_path="$1" + local status="$2" # success, failed, skipped + local details="$3" + + case "$status" in + success) + REPORT_DATA[total_converted]=$((${REPORT_DATA[total_converted]:-0} + 1)) + ;; + failed) + REPORT_DATA[total_failed]=$((${REPORT_DATA[total_failed]:-0} + 1)) + ;; + skipped) + REPORT_DATA[total_skipped]=$((${REPORT_DATA[total_skipped]:-0} + 1)) + ;; + esac + + REPORT_DATA[total_sites]=$((${REPORT_DATA[total_sites]:-0} + 1)) +} + +# Generate JSON report +generate_json_report() { + local end_time=$(date +%s) + local duration=$((end_time - ${REPORT_DATA[start_time]:-0})) + + cat < "$output_file" + echo "Report saved to: $output_file" + else + echo "$report_content" + fi +} + # OPTIMIZATION: Build cron command consistently # Centralizes cron command format (appears 4 times throughout script) # Returns: cron command string for wp-cron.php execution