Skip to content

Commit

Permalink
Merge branch 'hotfix/COVID-19_ReSchedule' into develop
Browse files Browse the repository at this point in the history
Plus1XP committed Jul 3, 2020
2 parents 1e831f1 + eb447d1 commit c30c46c
Showing 4 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions MotoiCal/Models/Formula1.cs
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ public class Formula1 : IRaceData, IMotorSport

public string[] ExcludedUrls => new string[]
{
"Test"
};

public string[] ExcludedClasses => new string[]
3 changes: 2 additions & 1 deletion MotoiCal/Models/MotoGP.cs
Original file line number Diff line number Diff line change
@@ -50,7 +50,8 @@ public class MotoGP : IRaceData, IMotorSport
public string[] ExcludedClasses => new string[]
{
"Moto2",
"Moto3"
"Moto3",
"MotoE"
};

public string[] ExcludedEvents => new string[]
30 changes: 24 additions & 6 deletions MotoiCal/Models/Scraper.cs
Original file line number Diff line number Diff line change
@@ -62,23 +62,24 @@ public bool IsEasterEggActive(string easterEggDate)
return DateTime.Parse(easterEggDate) == DateTime.Now.Date ? true : false;
}

// currentGrandPrix is initially set to null, then each loop is given the current GrandPRix value.
// currentSponser is initially set to null, then each loop is given the current Sponser value.
// This allows the stringbuilder to check if it needs to update header.
// * This was changed from checking again the currentGrandPrix in the COVID update due to multiple races at the same GrandPrix.
private string ProcessDisplayResults()
{
StringBuilder raceResults = new StringBuilder();

string currentGrandPrix = null;
string currentSponser = null;

foreach (var race in this.raceData)
{
string header = race.GrandPrix == currentGrandPrix ? string.Empty : race.DisplayHeader;
string header = race.Sponser == currentSponser ? string.Empty : race.DisplayHeader;
string body = race.DisplayBody;

raceResults.Append(header);
raceResults.AppendLine(body);

currentGrandPrix = race.GrandPrix;
currentSponser = race.Sponser;
}
return raceResults.ToString();
}
@@ -166,12 +167,16 @@ private void FindMotorSportSessions(IMotorSport motorSport, string url)
Debug.WriteLine($"Page scrape search time: {stopWatch.Elapsed.Seconds}.{stopWatch.Elapsed.Milliseconds / 10}");

string GrandPrix = this.doc.DocumentNode.SelectSingleNode(motorSport.GrandPrixNamePath)?.InnerText ?? "No Data";
// Location is empty in WSBK Catalunya
// Location is empty in WSBK Catalunya's URL.
string Location = this.doc.DocumentNode.SelectSingleNode(motorSport.LocationNamePath)?.InnerText ?? "No Data";
string Sponser = this.doc.DocumentNode.SelectSingleNode(motorSport.SponserNamePath)?.InnerText ?? "No Data";

// Adds location to empty WSBK Catalunya.
Location = this.WSBKCatalunyaLoctionFix(Sponser, Location);

//Debug.Assert(this.doc.DocumentNode.SelectNodes(motorSport.EventTablePath) != null);
//Debug.Assert(!GrandPrix.Contains("Mexico"));
//Debug.Assert(!GrandPrix.Contains("Spain"));
//Debug.WriteIf(motorSport.Url.Contains("https://www.worldsbk.com/en/event/ESP3/2020"), $"{GrandPrix}");

// MotoGP are updated the schedule, eventsTable loads 404.
if (this.doc.DocumentNode.SelectNodes(motorSport.EventTablePath) != null)
@@ -294,5 +299,18 @@ DateTime endUTC
break;
}
}

// Tempary fix to add WSBK Catalunya location untill WSBK update this.
private string WSBKCatalunyaLoctionFix(string sponser, string location)
{
if (sponser.Equals("Acerbis Catalunya Round") && location.Equals("No Data"))
{
return "Circuit de Barcelona-Catalunya";
}
else
{
return location;
}
}
}
}
4 changes: 2 additions & 2 deletions MotoiCal/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyFileVersion("1.1.1.0")]

// For Driver's nicknames please use the link below.
// https://en.wikipedia.org/wiki/List_of_motorsports_people_by_nickname

0 comments on commit c30c46c

Please sign in to comment.