Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PoliNetwork.Graduatorie.Parser/Objects/Json/DateFound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace PoliNetwork.Graduatorie.Parser.Objects.Json;
public class DateFound
{
public const string PathFileName = "dateFound.json";
public Dictionary<string, DateTime?>? FirstDate;
public SortedDictionary<string, DateTime?>? FirstDate;

public void WriteToFile(string dataFolder)
{
Expand All @@ -33,7 +33,7 @@ public void UpdateDateFound(Ranking variable)
{
var path = variable.GetPath().Trim();

FirstDate ??= new Dictionary<string, DateTime?>();
FirstDate ??= new SortedDictionary<string, DateTime?>();

var dateTime = new DateTime(variable.Year ?? DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day);
if (FirstDate.TryGetValue(path, out var oldValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class BySchoolYearCourseJson : IndexJsonBase
internal const string PathCustom = "bySchoolYearCourse.json";

//keys: school, year, course, location
public Dictionary<
public SortedDictionary<
SchoolEnum,
Dictionary<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>>
SortedDictionary<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>>
> Schools = new();

public static BySchoolYearCourseJson? From(RankingsSet? set)
Expand All @@ -48,30 +48,30 @@ public Dictionary<
return mainJson;
}

private static Dictionary<
private static SortedDictionary<
int,
Dictionary<string, Dictionary<string, List<SingleCourseJson>>>
SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>
> GetYearsDict(IEnumerable<IGrouping<int?, Ranking>> byYears)
{
var d =
new Dictionary<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>>();
new SortedDictionary<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>>();

foreach (var yearGroup in byYears) GetYearsDictSingle(yearGroup, d);

return d;
}

private static void GetYearsDictSingle(IGrouping<int?, Ranking> yearGroup,
IDictionary<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>> d)
SortedDictionary<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>> d)
{
if (yearGroup.Key != null) d.Add(yearGroup.Key.Value, GetCoursesDict(yearGroup));
}

private static Dictionary<string, Dictionary<string, List<SingleCourseJson>>> GetCoursesDict(
private static SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>> GetCoursesDict(
IEnumerable<Ranking> yearGroup
)
{
var d = new Dictionary<string, Dictionary<string, List<SingleCourseJson>>>();
var d = new SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>();

foreach (var ranking in yearGroup)
{
Expand All @@ -87,7 +87,7 @@ IEnumerable<Ranking> yearGroup
}

private static void AddCourseToDict(
IDictionary<string, Dictionary<string, List<SingleCourseJson>>> d,
SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>> d,
Ranking ranking,
IGrouping<string?, CourseTable> courseGroup
)
Expand All @@ -97,7 +97,7 @@ private static void AddCourseToDict(
return;

if (!d.ContainsKey(title))
d[title] = new Dictionary<string, List<SingleCourseJson>>();
d[title] = new SortedDictionary<string, List<SingleCourseJson>>();

var courseDict = d[title];
foreach (var course in courseGroup)
Expand Down Expand Up @@ -195,11 +195,11 @@ private static List<Ranking> RankingsAdd(BySchoolYearCourseJson mainJson, string
}

private static void RankingsAddSingleYearSchool(
KeyValuePair<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>> year,
KeyValuePair<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>> year,
string outFolder,
KeyValuePair<
SchoolEnum,
Dictionary<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>>
SortedDictionary<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>>
> school,
ICollection<Ranking> rankings
)
Expand All @@ -222,9 +222,9 @@ Action Selector(KeyValuePair<string, List<SingleCourseJson>> variable)
private static void RankingAdd(
KeyValuePair<
SchoolEnum,
Dictionary<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>>
SortedDictionary<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>>
> school,
KeyValuePair<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>> year,
KeyValuePair<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>> year,
string outFolder,
KeyValuePair<string, List<SingleCourseJson>> filename,
ICollection<Ranking> rankings
Expand All @@ -237,9 +237,9 @@ ICollection<Ranking> rankings
private static void RankingAddSingle(
KeyValuePair<
SchoolEnum,
Dictionary<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>>
SortedDictionary<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>>
> school,
KeyValuePair<int, Dictionary<string, Dictionary<string, List<SingleCourseJson>>>> year,
KeyValuePair<int, SortedDictionary<string, SortedDictionary<string, List<SingleCourseJson>>>> year,
string outFolder,
ICollection<Ranking> rankings,
SingleCourseJson variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BySchoolYearJson : IndexJsonBase
{
internal const string PathCustom = "bySchoolYear.json";

public Dictionary<SchoolEnum, Dictionary<int, IEnumerable<SingleCourseJson>>> Schools = new();
public SortedDictionary<SchoolEnum, SortedDictionary<int, IEnumerable<SingleCourseJson>>> Schools = new();

public static BySchoolYearJson? From(RankingsSet? set)
{
Expand All @@ -32,7 +32,7 @@ public class BySchoolYearJson : IndexJsonBase
continue;
var school = schoolGroup.Key.Value;

var schoolDict = new Dictionary<int, IEnumerable<SingleCourseJson>>();
var schoolDict = new SortedDictionary<int, IEnumerable<SingleCourseJson>>();

var byYears = schoolGroup.GroupBy(r => r.Year);
foreach (var yearGroup in byYears)
Expand All @@ -50,7 +50,7 @@ public class BySchoolYearJson : IndexJsonBase

private static void AddSchool(
IGrouping<int?, Ranking> yearGroup,
IDictionary<int, IEnumerable<SingleCourseJson>> schoolDict
SortedDictionary<int, IEnumerable<SingleCourseJson>> schoolDict
)
{
var yearGroupKey = yearGroup.Key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ByYearSchoolJson : IndexJsonBase
{
internal const string PathCustom = "byYearSchool.json";

public Dictionary<int, Dictionary<SchoolEnum, IEnumerable<SingleCourseJson>>> Years = new();
public SortedDictionary<int, SortedDictionary<SchoolEnum, IEnumerable<SingleCourseJson>>> Years = new();

public static ByYearSchoolJson? From(RankingsSet? set)
{
Expand All @@ -32,7 +32,7 @@ public class ByYearSchoolJson : IndexJsonBase
continue;
var year = yearGroup.Key.Value;

var yearDict = new Dictionary<SchoolEnum, IEnumerable<SingleCourseJson>>();
var yearDict = new SortedDictionary<SchoolEnum, IEnumerable<SingleCourseJson>>();

var bySchools = yearGroup.GroupBy(r => r.School);
foreach (var schoolGroup in bySchools)
Expand Down Expand Up @@ -87,7 +87,7 @@ private static List<Ranking> RankingsAdd(ByYearSchoolJson mainJson, string outFo
}

private static void RankingAdd(
KeyValuePair<int, Dictionary<SchoolEnum, IEnumerable<SingleCourseJson>>> year,
KeyValuePair<int, SortedDictionary<SchoolEnum, IEnumerable<SingleCourseJson>>> year,
KeyValuePair<SchoolEnum, IEnumerable<SingleCourseJson>> school,
string outFolder,
SingleCourseJson filename,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class StatsJson
private const string PathStats = "stats";

public DateTime LastUpdate = DateTime.UtcNow;
public Dictionary<int, StatsYear> Stats = new();
public SortedDictionary<int, StatsYear> Stats = new();

public static void Write(string outFolder, RankingsSet? rankingsSet, ArgsConfig argsConfig)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace PoliNetwork.Graduatorie.Parser.Objects.Json.Stats;
public class StatsYear
{
public int? NumStudents;
public Dictionary<SchoolEnum, StatsSchool> Schools = new();
public SortedDictionary<SchoolEnum, StatsSchool> Schools = new();

public int GetHashWithoutLastUpdate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class RankingSummary
public List<CourseTableStats>? CourseSummarized;
public int? HowManyCanEnroll;
public int? HowManyStudents;
public Dictionary<int, int>? ResultsSummarized; //key=score, value=howManyGotThatScore
public SortedDictionary<int, int>? ResultsSummarized; //key=score, value=howManyGotThatScore

public int GetHashWithoutLastUpdate()
{
Expand Down Expand Up @@ -61,11 +61,12 @@ public static RankingSummary From(Ranking ranking)
distinctBy
?.ToList();
var tableStatsList2 = Get(tableStatsList);
var resultsSummarized = new SortedDictionary<int, int>(keyValuePairs ?? new Dictionary<int, int>());
return new RankingSummary
{
HowManyCanEnroll = howManyCanEnroll,
HowManyStudents = byMeritRows?.Count,
ResultsSummarized = keyValuePairs,
ResultsSummarized = resultsSummarized,
CourseSummarized = tableStatsList2
};
}
Expand All @@ -82,11 +83,11 @@ private static List<CourseTableStats> Get(
}


private static Dictionary<int, int>? CalculateResultsScores(IReadOnlyCollection<StudentResult>? byMeritRows)
private static SortedDictionary<int, int>? CalculateResultsScores(IReadOnlyCollection<StudentResult>? byMeritRows)
{
if (byMeritRows == null) return null;

var results = new Dictionary<int, int>();
var results = new SortedDictionary<int, int>();
var enumerable = byMeritRows.Select(Round);
foreach (var score in enumerable)
{
Expand Down
4 changes: 2 additions & 2 deletions PoliNetwork.Graduatorie.Parser/Objects/StudentResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class StudentResult
public string? CanEnrollInto;
public int? EnglishCorrectAnswers;
public string? Id;
public Dictionary<string, bool>? Ofa; // maybe change it
public SortedDictionary<string, bool>? Ofa; // maybe change it
public int? PositionAbsolute;
public int? PositionCourse;
public decimal? Result;
public Dictionary<string, decimal>? SectionsResults;
public SortedDictionary<string, decimal>? SectionsResults;

public int GetHashWithoutLastUpdate()
{
Expand Down
4 changes: 2 additions & 2 deletions PoliNetwork.Graduatorie.Parser/Objects/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public static Table<T> Create(List<string> headers, List<string>? sections, List
return string.IsNullOrEmpty(fieldByIndex) ? null : fieldByIndex;
}

public Dictionary<string, int>? GetSectionsIndex()
public SortedDictionary<string, int>? GetSectionsIndex()
{
if (Sections is null) return null;
var dict = new Dictionary<string, int>();
var dict = new SortedDictionary<string, int>();
foreach (var section in Sections)
{
var index = Headers.FindIndex(h => h == section);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class CourseTableRow
public bool? CanEnroll;
public int? EnglishCorrectAnswers;
public string? Id;
public Dictionary<string, bool>? Ofa; // maybe change it
public SortedDictionary<string, bool>? Ofa; // maybe change it
public int? Position;
public decimal? Result;
public Dictionary<string, decimal>? SectionsResults;
public SortedDictionary<string, decimal>? SectionsResults;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public class CourseTableStats
public double? AverageBirthYear;
public double? AverageEnglishCorrectAnswers;
public decimal? AverageOfWhoPassed;
public Dictionary<string, decimal>? AveragePartialScores;
public SortedDictionary<string, decimal>? AveragePartialScores;
public decimal? AverageScoresOfAllStudents;
public int? HowManyCanEnroll;
public Dictionary<string, int>? HowManyOfa;
public SortedDictionary<string, int>? HowManyOfa;
public int? HowManyStudents;
public string? Location;
public decimal? MinScoreToEnroll;
Expand Down Expand Up @@ -145,14 +145,14 @@ public static CourseTableStats From(CourseTable courseTable)
return average == null ? null : Math.Round(average.Value, Decimals);
}

private static Dictionary<string, int>? HowManyOfaCalculate(
private static SortedDictionary<string, int>? HowManyOfaCalculate(
IReadOnlyCollection<StudentResult> courseTableRows
)
{
if (courseTableRows.Count == 0)
return null;

var result = new Dictionary<string, int>();
var result = new SortedDictionary<string, int>();

var keys = courseTableRows.Select(x => x.Ofa?.Keys);
var distinctKeys = DistinctKeys(keys);
Expand All @@ -166,14 +166,14 @@ IReadOnlyCollection<StudentResult> courseTableRows
return result;
}

private static Dictionary<string, decimal>? AveragePartialScoresCalculate(
private static SortedDictionary<string, decimal>? AveragePartialScoresCalculate(
IReadOnlyCollection<StudentResult> courseTableRows
)
{
if (courseTableRows.Count == 0)
return null;

var scores = new Dictionary<string, decimal>();
var scores = new SortedDictionary<string, decimal>();

var keys = courseTableRows.Select(x => x.SectionsResults?.Keys).ToList();
var keysDistinct = DistinctKeys(keys);
Expand All @@ -194,7 +194,7 @@ IReadOnlyCollection<StudentResult> courseTableRows


private static HashSet<string> DistinctKeys<T>(
IEnumerable<Dictionary<string, T>.KeyCollection?>? keysList
IEnumerable<SortedDictionary<string, T>.KeyCollection?>? keysList
)
{
var result = new HashSet<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MeritTableRow
public bool? CanEnroll;
public string? CanEnrollInto;
public string? Id;
public Dictionary<string, bool>? Ofa; // maybe change it
public SortedDictionary<string, bool>? Ofa; // maybe change it
public int? Position;
public decimal? Result;
}
Loading