From 76b92325765908fb01607cecbaa639209e27f279 Mon Sep 17 00:00:00 2001 From: roman-yagodin Date: Wed, 23 Jun 2021 09:17:44 +0300 Subject: [PATCH] Generate HTML for all available data files --- R7.Enrollment.Tests/Program.cs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/R7.Enrollment.Tests/Program.cs b/R7.Enrollment.Tests/Program.cs index 61588cc..4f3cb03 100644 --- a/R7.Enrollment.Tests/Program.cs +++ b/R7.Enrollment.Tests/Program.cs @@ -10,14 +10,25 @@ public class Program { static void Main (string[] args) { - var db = new TandemRatingsDb (); - db.Load ("./data/enr_rating_1696453372720271613.xml"); - //db.Load ("./data/enr_rating_1697112374642823421.xml"); - - RenderToFile (db, "output-print.html", new TandemRatingsRendererSettings ()); - RenderToFile (db, "output-web.html", new TandemRatingsRendererSettings { + var printSettings = new TandemRatingsRendererSettings (); + var webSettings = new TandemRatingsRendererSettings { UseBasicCompetitionHeader = true - }); + }; + + Directory.CreateDirectory ("output"); + + var dataFiles = Directory.GetFiles ("./data", "enr_rating_*.xml"); + foreach (var dataFile in dataFiles) { + var db = new TandemRatingsDb (); + db.Load (dataFile); + RenderToFile (db, $"./output/{FilenameFromCampaignTitle (db.EntrantRatingEnvironment.CampaignTitle)}-print.html", printSettings); + RenderToFile (db, $"./output/{FilenameFromCampaignTitle (db.EntrantRatingEnvironment.CampaignTitle)}-web.html", webSettings); + } + } + + static string FilenameFromCampaignTitle (string campaignTitle) + { + return campaignTitle.Replace ("21/22", "").Replace ("/", "_").Trim ().ToLower (); } static void RenderToFile (TandemRatingsDb db, string path, TandemRatingsRendererSettings settings)