Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
AnalyticsModuleStartDistances.cs
5
7{
12 {
13 private IPersonService _personService;
14
20 {
21 _personService = personService;
22 }
23
25 public bool AnalyticsAvailable => _personService.GetAllPersonStarts(onlyValidStarts: true).Count() > 0;
26
30 public Dictionary<ushort, int> NumberStartsPerDistance => _personService.GetAllPersonStarts(onlyValidStarts:true)
31 .GroupBy(s => s.CompetitionObj.Distance)
32 .ToDictionary(g => g.Key, g => g.Count())
33 .OrderByDescending(d => d.Value)
34 .ToDictionary();
35
39 public Dictionary<ushort, double> PercentageStartsPerDistance => NumberStartsPerDistance.ToDictionary(d => d.Key, d => (d.Value / (double)_personService.GetAllPersonStarts(onlyValidStarts:true).Count()) * 100)
40 .OrderByDescending(d => d.Value)
41 .ToDictionary();
42
45 {
46 DocXPlaceholderHelper.TextPlaceholders textPlaceholder = new DocXPlaceholderHelper.TextPlaceholders();
47 int maxNumStarts = NumberStartsPerDistance.Max(kv => kv.Value);
48 // Create a string for each dictionary entry including a ASCII diagramm (Format e.g.: 100m: 3x | ### 10%)
49 string moduleStartDistancesString = string.Join(Environment.NewLine,
51 .Select(kv =>
52 {
53 ushort distance = kv.Key;
54 string distanceString = $"{distance} m";
55 int count = kv.Value;
56 double percentage = PercentageStartsPerDistance.TryGetValue(distance, out var p) ? p : 0;
57 return $"{distanceString,5}: {count,2}x | {new string('#', count).PadRight(maxNumStarts)} {percentage.ToString("N1")}%";
58 }));
59
60 foreach (string placeholder in Placeholders.Placeholders_AnalyticsStartDistances) { textPlaceholder.Add(placeholder, moduleStartDistancesString); }
61 return textPlaceholder;
62 }
63
65 public List<string> SupportedDocumentPlaceholderKeys => new List<string>()
66 {
67 Placeholders.PLACEHOLDER_KEY_ANALYTICS_START_DISTANCES
68 };
69 }
70}
bool AnalyticsAvailable
Flag indicating if the analytics module has data.
List< string > SupportedDocumentPlaceholderKeys
List of all document placeholder keys that are supported by this analytics module....
Dictionary< ushort, int > NumberStartsPerDistance
Number of valid starts per distance.
AnalyticsModuleStartDistances(IPersonService personService)
Constructor for the AnalyticsModuleStartDistances
DocXPlaceholderHelper.TextPlaceholders CollectDocumentPlaceholderContents()
Collect the values for all document placeholders that are supported by this IAnalyticsModule....
Dictionary< ushort, double > PercentageStartsPerDistance
Percentage of valid starts per distance.
Interface for a service used to get and store a list of Person objects.