public void Update()
        {
            var lastRawIncomeTime = rawManager.GetLast().time;
            ////Day Start////
            var currentDay = UnixTimeHelper.GetCurrentDay();

            dayIncome = rawManager.GetLast().value - rawManager.GetRow(currentDay).value;
            var recentIncome      = manager.GetLast().value;
            var penultimateIncome = manager.GetPenultimate().value;

            dayTrend = recentIncome / penultimateIncome - 1;

            var lastDayIncomeArray = rawManager.GetInvertSlice(lastRawIncomeTime - 86400);
            var lastDayAmountArray = lastDayIncomeArray.Select(r => r.value).ToArray();

            dayAver     = StatisticHelper.GetAverageSpeed(lastDayAmountArray, 86400);
            dayExpected = StatisticHelper.GetMedianSpeed(lastDayAmountArray, 86400);
            ////Day End////

            ////Week Start////
            var weekDayIncome = manager.GetIncome(7);

            weekIncome = weekDayIncome;
            var twoWeekDayIncome = manager.GetIncome(14);
            var weeksDiff        = twoWeekDayIncome - weekDayIncome;

            weekTrend = (weeksDiff > 0) ? weekDayIncome / weeksDiff - 1 : 0.0;

            var weekIncomeArray       = rawManager.GetInvertSlice(lastRawIncomeTime - 604800);
            var weekIncomeAmountArray = weekIncomeArray.Select(r => r.value).ToArray();

            weekAver     = StatisticHelper.GetAverageSpeed(weekIncomeAmountArray, 604800);
            weekExpected = StatisticHelper.GetMedianSpeed(weekIncomeAmountArray, 604800);
            ////Week End////

            ////Total Start////
            var allIncome = manager.GetAll().Select(d => d.value);

            totalIncome = allIncome.Sum();
            totalTrend  = StatisticHelper.GetGlobalTrend(allIncome.ToArray());
            ////Total End////
        }
Exemple #2
0
        public void Update()
        {
            var lastRawIncomeTime     = rawManager.GetLast().time;
            var hourIncomeArray       = rawManager.GetInvertSlice(lastRawIncomeTime - 3600);
            var hourIncomeAmountArray = hourIncomeArray.Select(r => r.value).ToArray();

            ////Day Start////
            var dayIncomeArray       = rawManager.GetInvertSlice(lastRawIncomeTime - 86400);
            var dayIncomeAmountArray = dayIncomeArray.Select(r => r.value).ToArray();

            fullDayAverage = StatisticHelper.GetAverageSpeed(dayIncomeAmountArray, 86400);
            fullDayMedian  = StatisticHelper.GetMedianSpeed(dayIncomeAmountArray, 86400);
            hourDayAverage = StatisticHelper.GetAverageSpeed(hourIncomeAmountArray, 86400);
            hourDayMedian  = StatisticHelper.GetMedianSpeed(hourIncomeAmountArray, 86400);
            ////Day End////

            ////Week Start////
            var weekIncomeArray       = rawManager.GetInvertSlice(lastRawIncomeTime - 604800);
            var weekIncomeAmountArray = weekIncomeArray.Select(r => r.value).ToArray();

            fullWeekAverage = StatisticHelper.GetAverageSpeed(weekIncomeAmountArray, 604800);
            fullWeekMedian  = StatisticHelper.GetMedianSpeed(weekIncomeAmountArray, 604800);
            hourWeekAverage = StatisticHelper.GetAverageSpeed(hourIncomeAmountArray, 604800);
            hourWeekMedian  = StatisticHelper.GetMedianSpeed(hourIncomeAmountArray, 604800);
            ////Week End////

            ////Month Start////
            var monthIncomeArray = manager.GetInvertSlice(lastRawIncomeTime - 2629743);

            if (monthIncomeArray.Count() > 27)
            {
                var monthIncomeAmountArray = monthIncomeArray.Select(r => r.value).ToArray();
                fullMonthAverage = StatisticHelper.GetAverageSpeed(monthIncomeAmountArray, 2629743);
                fullMonthMedian  = StatisticHelper.GetMedianSpeed(monthIncomeAmountArray, 2629743);
            }

            hourMonthAverage = StatisticHelper.GetAverageSpeed(hourIncomeAmountArray, 2629743);
            hourMonthMedian  = StatisticHelper.GetMedianSpeed(hourIncomeAmountArray, 2629743);
            ////Month End////
        }