protected override Dictionary <string, decimal> CalculateReportData() { Logger.Info("Calculating Time spent on projects"); Dictionary <string, decimal> timePerProject = new Dictionary <string, decimal>(); var worklogsForProjectTimeSpent = _worklogsReporter.Report(); foreach (var worklogModels in worklogsForProjectTimeSpent.GroupBy(x => x.ProjectKey)) { timePerProject.Add(worklogModels.Key, worklogModels.Sum(x => x.Hours)); } return(timePerProject); }
protected override List <Worklog> CalculateReportData() { Logger.Info("Getting worklogs from database in range {0} to {1}", _from, _till); var result = new List <Worklog>(); var userNames = _userReporter.Report().Select(x => x.Login).ToList(); result = _jiraDbContext.Worklogs .Where(x => userNames.Contains(x.User) && x.Date >= _from && x.Date <= _till) .Select(WorklogMapper.ToDomain) .ToList(); return(result); }
protected override List <IEnumerable <Sinner> > CalculateReportData() { Logger.Info("Resolving sinners"); var users = _userReporter.Report(); var workLogs = _worklogsReporter.Report(); var attendance = _attendanceReporter.Report(); //var worklogCountSinners = users.Join(workLogs, u => u.UserName, w => w.User, (u, w) => new //{ // u.UserName, // u.IsTracking, // w.Date, // w.Hours //}) // .Where(uw => uw.Date.Equals(_dateOfSin) && uw.IsTracking) // .GroupBy(uw => uw.UserName) // .Select(guw => // new WorklogCountSinner // { // TotalHours = guw.Sum(x => x.Hours), // WorklogCount = guw.Count(), // SinDate = _dateOfSin, // SinnerLogin = guw.Key // }) // .Where(wcs => wcs.WorklogCount < WorklogCountSinner.CountThreshold); var longWorklogSinners = workLogs .Where(x => x.Date.Equals(_dateOfSin) && x.Hours >= LongWorklogSinner.LongWorklogThreshold) .Join(users, w => w.User, u => u.Login, (w, u) => new { w.Hours, w.User, u.IsTracking }) .Where(x => x.IsTracking.HasValue && x.IsTracking.Value) .Select(x => new LongWorklogSinner { SinnerLogin = x.User, Hours = x.Hours, SinDate = _dateOfSin }); var timeTrackedSinners = attendance .Where(x => x.Date.Equals(_dateOfSin) && (x.TotalHours <TimeTrackedSinner.LowHoursThreshold || x.TotalHours> TimeTrackedSinner.HighHoursThreshold)) .Join(users, a => a.User, u => u.Login, (a, u) => new { a.User, a.AbsenceTotal, a.TotalHours, a.HoursWorked, u.IsTracking }) .Where(x => x.IsTracking.HasValue && x.IsTracking.Value) .Select(x => new TimeTrackedSinner { SinnerLogin = x.User, Absence = x.AbsenceTotal, TotalHours = x.TotalHours, TimeTracked = x.HoursWorked, SinDate = _dateOfSin }); var noTimeTrackedSinners = attendance .Where(x => x.Date.Equals(_dateOfSin) && x.TotalHours == 0) .Join(users, a => a.User, u => u.Login, (a, u) => new { a.User, u.IsTracking }) .Where(x => x.IsTracking.HasValue && x.IsTracking.Value) .Select(x => new NoTimeTrackedSinner { SinnerLogin = x.User, SinDate = _dateOfSin }); var sinners = new List <IEnumerable <Sinner> > { longWorklogSinners, timeTrackedSinners, noTimeTrackedSinners }; return(sinners); }
public void Write() { _writable.Write(_reporter.Report()); }