コード例 #1
0
        public static List <StatisticsRaw> ProjectRaw(ManoContext DB, Guid pid, List <Commit> commits)
        {
            var project = DB.Projects.Single(x => x.Id == pid);
            var emails  = DB.Emails.Where(x => x.UserId == project.UserId).Select(x => x.EmailAddress).ToList();

            if (commits
                .Where(x => emails.Contains(x.Email))
                .Count() == 0)
            {
                return(new List <StatisticsRaw>());
            }

            var ret = commits
                      .GroupBy(x => DB.Extensions.Where(y => y.Id == x.Extension && (y.Type == TechnologyType.编程语言 || y.Type == TechnologyType.序列化格式)).SingleOrDefault() != null
                ? new { Type = DB.Extensions.Where(y => y.Id == x.Extension && (y.Type == TechnologyType.编程语言 || y.Type == TechnologyType.序列化格式)).SingleOrDefault().Type, Technology = DB.Extensions.Where(y => y.Id == x.Extension && (y.Type == TechnologyType.编程语言 || y.Type == TechnologyType.序列化格式)).SingleOrDefault().Technology }
                : new { Type = TechnologyType.其他, Technology = "其他" })
                      .Select(x => new StatisticsRaw
            {
                Technology = x.Key != null ? x.Key.Technology : "其他",
                Mine       = x.Where(y => emails.Contains(y.Email)).Count() > 0 ? x.Where(y => emails.Contains(y.Email)).Sum(y => y.Additions + y.Deletions) : 0,
                Total      = x.Count() > 0 ? x.Sum(y => y.Additions + y.Deletions) : 0,
                Begin      = x.Where(y => emails.Contains(y.Email)).Count() > 0 ? x.Where(y => emails.Contains(y.Email)).Min(y => y.Time) : DateTime.Now,
                End        = x.Where(y => emails.Contains(y.Email)).Count() > 0 ? x.Where(y => emails.Contains(y.Email)).Max(y => y.Time) : DateTime.Now,
                Type       = x.Key != null ? x.Key.Type : TechnologyType.其他
            })
                      .ToList();

            return(ret);
        }
コード例 #2
0
        public static List <StatisticsRaw> UserRaw(ManoContext DB, long uid)
        {
            var projects = DB.Projects.Where(x => x.UserId == uid).Select(x => x.Statistics).ToList();

            return(projects
                   .SelectMany(x => JsonConvert.DeserializeObject <List <StatisticsRaw> >(x))
                   .GroupBy(x => new { Technology = x.Technology, Type = x.Type })
                   .Select(x => new StatisticsRaw
            {
                Technology = x.Key.Technology,
                Mine = x.Sum(y => y.Mine),
                Total = x.Sum(y => y.Total),
                Begin = x.Min(y => y.Begin),
                End = x.Max(y => y.End),
                Type = x.Key.Type
            })
                   .ToList());
        }