Created
November 30, 2020 19:53
-
-
Save Theoistic/770e75aefa2593de013814cc330ef070 to your computer and use it in GitHub Desktop.
Linq Gone Wrong
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _w = new List<object>(); | |
weeks.ForEach(x => | |
{ | |
var locations = new List<object>(); | |
x.GroupBy(c => c.Location.Name).ForEach(l => { | |
var eh = new | |
{ | |
Answers = l.GroupBy(n => n.Value) | |
.Select(n => new | |
{ | |
MetricName = n.Key, | |
MetricCount = n.Count() | |
} | |
) | |
.OrderBy(n => n.MetricName), | |
responseRate = responseRate(x.Key + $" Location: {l.Key}", l.Count()) | |
}; | |
var days = new List<object>(); | |
l.GroupBy(n => n.Submitted.DayOfWeek).ForEach(j => | |
{ | |
var eh2 = new | |
{ | |
Answers = j.GroupBy(n => n.Value) | |
.Select(n => new | |
{ | |
MetricName = n.Key, | |
MetricCount = n.Count() | |
} | |
) | |
.OrderBy(n => n.MetricName), | |
//responseRate = responseRateDay(j.Key, j.Count()) | |
}; | |
days.Add(new { Day = j.Key.ToString(), Data = eh2 }); | |
}); | |
locations.Add(new { Location = l.Key, DailyData = days, WeeklyData = eh }); | |
}); | |
var totalByWeek = new | |
{ | |
Answers = x.GroupBy(n => n.Value) | |
.Select(n => new | |
{ | |
MetricName = n.Key, | |
MetricCount = n.Count() | |
} | |
) | |
.OrderBy(n => n.MetricName), | |
responseRate = reponseRateTotal(x.Key, x.Count()) | |
}; | |
var days = new List<object>(); | |
x.GroupBy(n => n.Submitted.DayOfWeek).ForEach(j => | |
{ | |
var eh2 = new | |
{ | |
Answers = j.GroupBy(n => n.Value) | |
.Select(n => new | |
{ | |
MetricName = n.Key, | |
MetricCount = n.Count() | |
} | |
) | |
.OrderBy(n => n.MetricName), | |
}; | |
days.Add(new { Day = j.Key.ToString(), Data = eh2 }); | |
}); | |
_w.Add(new { | |
WeekOfYear = x.Key, | |
Total = new | |
{ | |
WeeklyData = totalByWeek, | |
DailyData = days, | |
}, | |
Locations = locations | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment