Skip to content

Commit

Permalink
refactor: RankingsSet.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzocorallo committed Jul 7, 2024
1 parent 5cce969 commit 1dcef86
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions PoliNetwork.Graduatorie.Parser/Objects/RankingNS/RankingsSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,19 @@ public RankingsSet()
LastUpdate = DateTime.UtcNow;
}


public void AddRanking(Ranking ranking)
{
var alreadyPresent = Contains(ranking);
if (!alreadyPresent)
Rankings.Add(ranking);

if (LastUpdate == null || ranking.LastUpdate.Date > LastUpdate?.Date) LastUpdate = ranking.LastUpdate;
}

public bool Contains(Ranking ranking)
{
return Rankings.Any(v => v.IsSimilarTo(ranking));
}

public void Merge(RankingsSet set)
public void Merge(RankingsSet newSet)
{
foreach (var ranking in set.Rankings) AddRanking(ranking);
foreach (var ranking in newSet.Rankings)
{
var alreadyPresent = Rankings.Any(v => v.IsSimilarTo(ranking));
if (!alreadyPresent)
{
Rankings.Add(ranking);

if (LastUpdate == null || ranking.LastUpdate.Date > LastUpdate?.Date)
LastUpdate = ranking.LastUpdate;
}
}
}

public void WriteAllRankings(string outFolder, bool forceReparse = false)
Expand Down

0 comments on commit 1dcef86

Please sign in to comment.