Ejemplo n.º 1
0
        public HttpResponseMessage LoadTrackData()
        {
            var factory = new TrelloBoardServiceFactory();
            var trello = factory.CreateTrelloBoardService(ConfigurationManager.AppSettings["TrelloKey"],
                                                          ConfigurationManager.AppSettings["TrelloToken"],
                                                          ConfigurationManager.AppSettings["TrelloBoard"]);
            var cardCounts = trello.GetColumnCardCounts();
            var members = trello.GetMembers();

            var trackData = new TrackData { ColumnCardCounts = cardCounts, Members = members };

            return Request.CreateResponse(trackData);
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";

            var trelloKey = ConfigurationManager.AppSettings["TrelloKey"];
            var trelloToken = ConfigurationManager.AppSettings["TrelloToken"];
            var trelloBoard = ConfigurationManager.AppSettings["TrelloBoard"];
            var trello = new TrelloBoardServiceFactory().CreateTrelloBoardService(trelloKey,trelloToken, trelloBoard);

            var teamMemberStatusService = new TeamMemberStatusService(_hackTrackDbContext);
            var githubClient = new GitHubRestClientFactory().Create();
            var committersService = new RepoCommitsService(githubClient);
            var contributorService = new RepoContributorStatisticsService(githubClient);

            var gitHubOwner = ConfigurationManager.AppSettings["GitHub.Owner"];
            var gitHubRepository = ConfigurationManager.AppSettings["GitHub.Repository"];
            var totalCommits = committersService.GetCommits(gitHubOwner, gitHubRepository);
            var lastHourCommits = committersService.GetCommitsForHour(gitHubOwner, gitHubRepository, DateTime.UtcNow.AddHours(-1));

            var cardCounts = trello.GetColumnCardCounts();
            var members = trello.GetMembers();
            var cardsPerMember = new Dictionary<BoardMember, IEnumerable<BoardCard>>();
            var statusesPerMember = new Dictionary<BoardMember, IEnumerable<TeamMemberStatus>>();
            var boardMembers = members as IList<BoardMember> ?? members.ToList();

            var teamMembers = new List<TeamMemberStatuses>();

            foreach (var member in boardMembers)
            {
                var cards = trello.GetCurrentCardsForMember(member);
                var statuses = teamMemberStatusService.GetTeamMemberStatuses(member.Id);
                var newthing = GetDefaultStatuses();
                if (statuses != null)
                {
                    foreach (var status in statuses)
                    {
                        newthing[status.StatusType] = status;
                    }
                }
                cardsPerMember.Add(member, cards);
                teamMembers.Add(new TeamMemberStatuses {TeamMember = member, MemberStatuses = newthing} );
            }

            var persistenceService = new TrelloMemberPersistenceService(_hackTrackDbContext);
            members.ForEach(persistenceService.PersistMember);

            var topContributor = contributorService.GetTopContributorStatistics(gitHubOwner, gitHubRepository);

            var model = new TrackData {ColumnCardCounts = cardCounts,
                Members = boardMembers,
                CardsPerMember = cardsPerMember,
                Statuses = statusesPerMember,
                TotalCommits = totalCommits.Count(),
                CommitsLastHour = lastHourCommits.Count(),
                TeamMembers = teamMembers,
                TopComitterPicUrl = topContributor.author.avatar_url + "&s=108"//"https://0.gravatar.com/avatar/9a3c279b88985ca19876111fe5458ec2?d=https%3A%2F%2Fidenticons.github.com%2Ff61eb54e6270b06dc6542c5dc2f19a96.png&r=x&s=107"
            };

            return View(model);
        }