Пример #1
0
        public async Task <List <Build> > SelectFamily(ProjectFamily family, int limit = -1, int skip = 0)
        {
            IFindFluent <Build, Build> query = _buildCollection.Find(new BsonDocument(nameof(Build.Family), family)).Sort(sortByOrder).Skip(skip);

            if (limit > 0)
            {
                query = query.Limit(limit);
            }

            return(await query.ToListAsync());
        }
Пример #2
0
        public Task <ProjectFamily[]> SelectAllFamilies(int limit = -1, int skip = 0) => Task.Run(() =>
        {
            Array values = Enum.GetValues(typeof(ProjectFamily));
            if (values.Length == 0)
            {
                return(Array.Empty <ProjectFamily>());
            }

            var valuesWithoutNone = new ProjectFamily[values.Length - 1];
            for (int i = 0,
                 j = values.Length - 1;
                 j > 0;
                 j--, i++)
            {
                valuesWithoutNone[i] = (ProjectFamily)values.GetValue(j);
            }

            return(valuesWithoutNone);
        });
Пример #3
0
        public async Task <ActionResult> ViewFamilyPage(ProjectFamily family, int page)
        {
            ViewBag.MetaItem = await _mModel.SelectById(new MetaItemKey
            {
                Type  = MetaType.Family,
                Value = family.ToString()
            });

            ViewBag.Item   = family;
            ViewBag.ItemId = MvcExtensions.GetDisplayDescriptionForEnum(family);

            var builds = await _bModel.SelectFamily(family, PAGE_SIZE, (page - 1) *PAGE_SIZE);

            ViewBag.PageNumber = page;
            ViewBag.PageCount  =
                Math.Ceiling(Convert.ToDouble(await _bModel.SelectFamilyCount(family)) / Convert.ToDouble(PAGE_SIZE));

            if (ViewBag.PageNumber > ViewBag.PageCount)
            {
                return(new HttpNotFoundResult());
            }

            return(View("viewFamily", builds));
        }
Пример #4
0
        public async Task <FrontPage> SelectFrontPage(ProjectFamily family)
        {
            FrontPage fp = new FrontPage();

            IFindFluent <Build, Build> query = _buildCollection.Find(new BsonDocument
            {
                { "$where", "!this.LabUrl.contains(\"xbox\")" },
                {
                    nameof(Build.Family), family
                }
            }).Sort(sortByCompileDate).Limit(1);

            fp.CurrentCanary = await query.FirstOrDefaultAsync();

            query = _buildCollection.Find(new BsonDocument
            {
                { "$where", "!this.LabUrl.contains(\"xbox\")" },
                {
                    nameof(Build.Family), family
                },
                {
                    nameof(Build.MajorVersion), 10
                },
                {
                    nameof(Build.SourceType), new BsonDocument
                    {
                        {
                            "$in", new BsonArray
                            {
                                TypeOfSource.PublicRelease,
                                TypeOfSource.UpdateGDR
                            }
                        }
                    }
                }
            }).Sort(sortByCompileDate).Limit(1);
            fp.CurrentInsider = await query.FirstOrDefaultAsync();

            query = _buildCollection.Find(new BsonDocument
            {
                { "$where", "((this.MajorVersion === 10 && this.LabUrl.contains(\"_release\")) || this.MajorVersion < 10) && !this.LabUrl.contains(\"xbox\")" },
                {
                    nameof(Build.Family), family
                },
                {
                    nameof(Build.SourceType), new BsonDocument
                    {
                        {
                            "$in", new BsonArray
                            {
                                TypeOfSource.PublicRelease,
                                TypeOfSource.UpdateGDR
                            }
                        }
                    }
                }
            }).Sort(sortByCompileDate).Limit(1);
            fp.CurrentRelease = await query.FirstOrDefaultAsync();

            query = _buildCollection.Find(new BsonDocument
            {
                { "$where", "this.LabUrl.contains(\"xbox\")" },
                {
                    nameof(Build.Family), family
                }
            }).Sort(sortByCompileDate).Limit(1);
            fp.CurrentXbox = await query.FirstOrDefaultAsync();

            return(fp);
        }
Пример #5
0
 public async Task <long> SelectFamilyCount(ProjectFamily family) => await _buildCollection.CountAsync(new BsonDocument(nameof(Build.Family), family));
Пример #6
0
 public async Task <ActionResult> ViewFamily(ProjectFamily family)
 {
     return(await ViewFamilyPage(family, 1));
 }