예제 #1
0
        public ActionResult GetStatsAsync(int pid, int relid, string period, string arg)
        {
            DateTime   end;
            DateTime   start;
            TimePeriod pd = TimePeriod.Auto;

            DownloadStats.ParseQuery(period, arg, out pd, out start, out end);
            DownloadStats stats = relid != -1 ? CurrentUserModel.Stats.GetReleaseDownloadStats(relid, pd, start, end) : CurrentUserModel.Stats.GetProjectDownloadStats(pid, pd, start, end);

            return(Content(stats.ToJson()));
        }
예제 #2
0
        public ActionResult GetRepoDownloadStatsAsync(string period, string arg)
        {
            CurrentUserModel.CheckIsAdmin();
            DateTime   end;
            DateTime   start;
            TimePeriod pd = TimePeriod.Auto;

            DownloadStats.ParseQuery(period, arg, out pd, out start, out end);
            DownloadStats stats = CurrentUserModel.Stats.GetTotalRepoDownloadStats(pd, start, end);

            return(Content(stats.ToJson()));
        }
예제 #3
0
        public ActionResult GetTopDownloads(string period, string arg)
        {
            CurrentUserModel.CheckIsAdmin();
            DateTime   end;
            DateTime   start;
            TimePeriod pd = TimePeriod.Auto;

            DownloadStats.ParseQuery(period, arg, out pd, out start, out end);

            List <DownloadInfo> stats = CurrentUserModel.Stats.GetTopDownloads(start, end);
            StringBuilder       sb    = new StringBuilder();

            foreach (var di in stats)
            {
                if (sb.Length > 0)
                {
                    sb.Append(',');
                }
                sb.AppendFormat("{{\"count\":{0},\"platform\":\"{1}\",\"projectId\":{2},\"appVersion\":\"{3}\",\"name\":\"{4}\"}}", di.Count, di.Platform, di.Release.ProjectId, di.Release.TargetAppVersion, di.Release.AddinName + " v" + di.Release.Version);
            }
            return(Content("[" + sb + "]"));
        }