#!/usr/bin/env elixir # Test script to verify the monitoring date/datetime conversion fix # Test dates date_from = ~D[2025-07-17] date_to = ~D[2025-08-16] IO.puts("Testing DaProductApp.Monitoring functions with date parameters...") IO.puts("Date from: #{date_from}") IO.puts("Date to: #{date_to}") # This would previously cause the error: # value `~D[2025-07-17]` in `where` cannot be cast to type :utc_datetime try do # Test transaction stats result = DaProductApp.Monitoring.get_transaction_stats(date_from, date_to) IO.puts("āœ… get_transaction_stats/2 works correctly") IO.inspect(result, label: "Transaction stats") # Test QR validation stats result = DaProductApp.Monitoring.get_qr_validation_stats(date_from, date_to) IO.puts("āœ… get_qr_validation_stats/2 works correctly") IO.inspect(result, label: "QR validation stats") # Test dashboard analytics result = DaProductApp.Monitoring.get_dashboard_analytics(date_from, date_to) IO.puts("āœ… get_dashboard_analytics/2 works correctly") IO.inspect(result, label: "Dashboard analytics") # Test corridor performance result = DaProductApp.Monitoring.get_corridor_performance(date_from, date_to) IO.puts("āœ… get_corridor_performance/2 works correctly") IO.inspect(result, label: "Corridor performance") IO.puts("\nšŸŽ‰ All monitoring functions work correctly with Date parameters!") rescue e -> IO.puts("āŒ Error occurred: #{inspect(e)}") IO.puts("The fix may not be working correctly.") end