コード例 #1
0
        /*
         *
         *  1a -  5 happiest people in the organisation. This is the highest aggregated hig scores over the last 12 months. Display small avatar, name and job title for each.
            1b- 5 'saddest' people - same as above but lowest aggregate hig scores - DISCOUNT users with no hig scores
            1c - chart of hig scores and sickness days over time (12 months) for the whole organisation (similar to the team page chart but for whole organisation)

            2- Praise and concern
            2a - chart of praises and concerns for whole organisation over time (12 months) - similar to existing team page
            2b - top 5 praised employees over last 12 months - show avatar, name and job title. based on aggregate of praise value.
            2b  top 5 concern employees over last 12 months - show avatar, name and job title. based on aggregate of concern value. 
         * 
         */
        public JsonResult DashboardData()
        {

            //get data for dashboard
            var sicknesstypes = GetSicknessTypesData();

            var higs = GetHIGData();
            var happiest = higs.OrderByDescending(h => h.RawValue).Take(10);
            var saddest = higs.OrderBy(h => h.RawValue).Take(10);


            var viewmodel = KPIHelper.GetKPIViewModel(OrgStore, 12);
            //viewmodel.Totals.Remove("Concern");
            //viewmodel.GraphData.Remove("Concern"); 
            var kpidata = viewmodel;
            var higandsicknessdata = new KpiDataViewModel { Totals = new Dictionary<string, int> { { "Sickness", kpidata.Totals["Sickness"] } }, GraphData = new Dictionary<string, GraphSeries> { { "Sickness", kpidata.GraphData["Sickness"] } } };
            var praiseandconcerndata = new KpiDataViewModel { Totals = new Dictionary<string, int> { { "Praise", kpidata.Totals["Praise"] }, { "Concern", kpidata.Totals["Concern"] } }, GraphData = new Dictionary<string, GraphSeries> { { "Praise", kpidata.GraphData["Praise"] }, { "Concern", kpidata.GraphData["Concern"] } } };

            var praise = GetPraiseData();
            var concern = GetConcernData();

            return Json(new { sicknesstypedata = sicknesstypes, praisedata = praise, happiestdata = happiest, saddestdata = saddest, kpidata = kpidata, higandsicknessdata = higandsicknessdata, praiseandconcerndata = praiseandconcerndata, concerndata = concern });
        }
コード例 #2
0
 public TeamMemberViewModel()
 {
     KpiData = new KpiDataViewModel();
 }
コード例 #3
0
ファイル: KPIHelper.cs プロジェクト: andyevans2000/Illuminate
        public static KpiDataViewModel GetKPIViewModel(IDocumentStore store, int monthsToGoBack = 12, IEnumerable<string> users = null)
        {
            var viewmodel = new KpiDataViewModel();

            using (var session = store.OpenSession())
            {
 
                //when does the time period for the rolling kpi period go to
                var aWhileAgo = DateTime.Now.AddMonths(0 - monthsToGoBack);
                var awaKey = (aWhileAgo.Year*100) + aWhileAgo.Month;
                //query the multi-map reduce index for the given timeframe and users
                var query = session.Query<KPIIndex.Result, KPIIndex>();
                var higquery = session.Query<HIGKPIIndex.Result, HIGKPIIndex>();
                if (users != null)
                {
                    query = query.Where(o => o.UserId.In(users));
                    higquery = higquery.Where(o => o.UserId.In(users));
                }
                var kpis = query.Where(o => o.YearMonth >= awaKey)
                                .Take(1024)
                                .ToList();
                var higkpis = higquery.Where(o => o.YearMonth >= awaKey)
                                .Take(1024)
                                .ToList();

                

                //sum the kpis data
                viewmodel.Totals.Add(Concern, kpis.Sum(o => o.ConcernCount));
                viewmodel.Totals.Add(Praise, kpis.Sum(o => o.PraiseCount));
                viewmodel.Totals.Add(Sickness, kpis.Sum(o => o.SicknessCount));
                if (higkpis.Count > 1)
                    viewmodel.HigAverage = (int) Math.Round(Math.Round(higkpis.Average(o => o.RawHIGValue)*2)/2);
                else
                    viewmodel.HigAverage = 0;

                //get kpi data for the graphs. MUST have an entry for each month. So prefill it. 
                var kpigraphdata = new Dictionary<string, GraphSeries>
                                       {
                                           {Concern, new GraphSeries {Title = Concern, Filled = true, Colour = "#FF0000"}},
                                           {Praise, new GraphSeries {Title = Praise, Filled = true, Colour = "#00FF00"}},
                                           {Sickness, new GraphSeries {Title = Sickness, Filled = true, Colour = "#0000FF"}},
                                           {HIG, new GraphSeries {Title = HIG, YAxis = 2, Filled = false, Colour = "#FFFF00"}},
                                       };

                for (var d = aWhileAgo; d <= DateTime.Now; d = d.AddMonths(1))
                {
                    //does an entry exist?
                    var entries = kpis.Where(k => k.Year == d.Year && k.Month == d.Month);
                    var higentries = higkpis.Where(k => k.Year == d.Year && k.Month == d.Month);
                    if (!entries.Any())
                    {
                        kpigraphdata[Concern].Points.Add(new List<object> { new DateTime(d.Year, d.Month, 1), 0 });
                        kpigraphdata[Praise].Points.Add(new List<object> { new DateTime(d.Year, d.Month, 1), 0 });
                        kpigraphdata[Sickness].Points.Add(new List<object> { new DateTime(d.Year, d.Month, 1), 0 });
                        
                    }
                    else
                    {
                        kpigraphdata[Concern].Points.Add(new List<object> { new DateTime(d.Year, d.Month, 1), entries.Sum(o => o.ConcernCount) });
                        kpigraphdata[Praise].Points.Add(new List<object> { new DateTime(d.Year, d.Month, 1), entries.Sum(o => o.PraiseCount) });
                        kpigraphdata[Sickness].Points.Add(new List<object> { new DateTime(d.Year, d.Month, 1), entries.Sum(o => o.SicknessCount) });
                        
                    }
                    kpigraphdata[HIG].Points.Add(!higentries.Any()
                                                     ? new List<object> {new DateTime(d.Year, d.Month, 1), 0}
                                                     : new List<object>
                                                           {
                                                               new DateTime(d.Year, d.Month, 1),
                                                               higentries.Sum(o => o.RawHIGValue)
                                                           });
                }
                viewmodel.GraphData = kpigraphdata;

                return viewmodel;
            }
        }