Ejemplo n.º 1
0
        public async Task <ActionResult> Users()
        {
            if (!HttpContext.Request.IsAjaxRequest())
            {
                return(null);
            }

            IList <UserProfile>   users          = (await _usersProvider.GetAllUsers());
            IList <UserViewModel> usersViewModel = new List <UserViewModel>(users.Count);

            foreach (UserProfile user in users)
            {
                UserViewModel userViewModel = ConvertUserProfileToUserViewModel(user);
                usersViewModel.Add(userViewModel);
            }

            return(View("_Users", usersViewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> TestCase(int id)
        {
            var gitClient = new GithubApiClient();
            var model     = new TestCaseViewModel
            {
                TestCase = await _testLabProvider.GetTest(id),
                Users    = await _usersProvider.GetAllUsers(),
            };

            model.GitHubComments = gitClient.GetCommentsForIssue(model.TestCase.GitHubId);
            if (model.TestCase.PullRequestId == 0)
            {
                return(View(model));
            }
            try
            {
                model.PullRequestComment = gitClient.GetPullRequestComments(model.TestCase.PullRequestId);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <IEnumerable <UserModel> > > Get()
        {
            var users = await _usersProvider.GetAllUsers();

            return(Ok(users));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Index()
        {
            var folder = await _foldersProvider.GetActiveFolder();

            SystemUser user = null;

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                user = await _usersProvider.GetUser(HttpContext.User.GetUserId());

                folder = user.SelectedFolder;
            }

            var platforms = new string[] { "osx", "win7", "win", "linux" };

            var runs = folder.Runs;

            var model = new DashboardDataModel
            {
                FailedTests = new List <FailedTestPerPlatform>(),
                Users       = await _usersProvider.GetAllUsers()
            };

            foreach (var platform in platforms)
            {
                model.LatestStats.Add(await _runsProvider.GetLatestRunForEnvironment(platform, folder.Id));
            }

            foreach (var run in runs.GroupBy(p => p.Environment).OrderBy(p => p.Key))
            {
                var runner = run.OrderByDescending(p => p.ReportTime).FirstOrDefault();
                model.LatestResults.Add(runner);
                var allTestsInfo = await _runsProvider.GetAllTestsInfo();

                foreach (var test in runner.FailedTests)
                {
                    var testInfo   = allTestsInfo.FirstOrDefault(p => p.TestName == test + ".py");
                    var failedTest = new FailedTestPerPlatform
                    {
                        LinuxRunId  = runs.Where(p => p.Environment == "linux").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id,
                        OsxRunId    = runs.Where(p => p.Environment == "osx").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id,
                        Win10RunId  = runs.Where(p => p.Environment == "win").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id,
                        Win7RunId   = runs.Where(p => p.Environment == "win7").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id,
                        TestId      = runs.OrderByDescending(p => p.ReportTime).Where(p => p.Tests != null).SelectMany(z => z.Tests).FirstOrDefault(q => q.Name == test)?.Id,
                        Test        = test,
                        Author      = testInfo?.AuthorLogin,
                        Suit        = testInfo?.SuiteName,
                        CurrentUser = user,
                        Linux       = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "linux")?.FailedTests.ToList().Exists(p => p == test),
                        Windows7    = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "win7")?.FailedTests.ToList().Exists(p => p == test),
                        Osx         = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "osx")?.FailedTests.ToList().Exists(p => p == test),
                        Windows10   = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "win")?.FailedTests.ToList().Exists(p => p == test)
                    };

                    model.FailedTests.Add(failedTest);
                }
            }

            model.FailedTests = model.FailedTests.Distinct().ToList();

            //Historic data
            var groupedEnvironment = runs.GroupBy(p => p.Environment);

            model.HistoricData = new List <HistoricData>();
            foreach (var grouping in groupedEnvironment)
            {
                var newHistoricData = new HistoricData {
                    Platform = grouping.Key
                };
                var groupedDate = grouping.GroupBy(p => p.ReportTime.Date).OrderBy(p => p.Key);
                newHistoricData.HistoricDataItems = new List <HistoricDataItems>();
                foreach (var dt in groupedDate)
                {
                    var item = dt.OrderByDescending(p => p.Total).FirstOrDefault();
                    if (item != null)
                    {
                        newHistoricData.HistoricDataItems.Add(new HistoricDataItems
                        {
                            DateLabel = dt.Key.ToShortDateString(),
                            Blocked   = item.Blocked,
                            Failed    = item.Failed,
                            Passed    = item.Passed,
                            Skipped   = item.Skipped,
                            Total     = item.Total
                        });
                    }
                }
                model.HistoricData.Add(newHistoricData);
            }

            return(View(model));
        }