Exemplo n.º 1
0
 //TODO: move func to model
 private static void AddDuration(CardStatsModel cardStatsModel, string listId, TimeSpan duration)
 {
     if (cardStatsModel.ListStats.ContainsKey(listId))
     {
         cardStatsModel.ListStats[listId] = cardStatsModel.ListStats[listId] + duration;
     }
     else
     {
         cardStatsModel.ListStats.Add(listId, duration);
     }
 }
Exemplo n.º 2
0
        private static ReportRow BuildCardStats(CardStatsModel cardStats, string[] listNames, Dictionary <string, string> listNameToIdIndex)
        {
            var reportRow = ReportRow.Create(cardStats.Name, cardStats.Size, FormatTimeSpan(cardStats.CycleTime));

            foreach (var listName in listNames)
            {
                var listId = listNameToIdIndex[listName];
                if (cardStats.ListStats.ContainsKey(listId))
                {
                    reportRow.Append(FormatTimeSpan(cardStats.ListStats[listId]));
                }
            }
            return(reportRow);
        }
Exemplo n.º 3
0
        //TODO: verify what time trello sends at client
        //TODO: unit tests
        public CardStatsModel Build(string cardId)
        {
            var cardHistory = cardHistoryService.Get(cardId);
            var card        = taskManagerClient.GetCard(cardId);
            var result      = new CardStatsModel
            {
                Id           = cardId,
                Name         = card.Name,
                LastActivity = card.LastActivity
            };

            result.SetLabels(card.Labels);

            if (cardHistory.Movements.Length <= 1)
            {
                return(result);
            }

            if (cardHistory.CreateDate.HasValue)
            {
                AddDuration(result, cardHistory.Movements[0].FromListId, cardHistory.Movements[0].Date.Subtract(cardHistory.CreateDate.Value));
            }
            for (var i = 0; i < cardHistory.Movements.Length - 1; i++)
            {
                if (!string.Equals(cardHistory.Movements[i].ToListId, cardHistory.Movements[i + 1].FromListId))
                {
                    loggerFactory.Get <CardStatsBuilder>()
                    .LogError($"Broken actions chain obtained for cardId {cardId}. To {cardHistory.Movements[i].ToListId}, From {cardHistory.Movements[i + 1].FromListId}, chain index {i}.");
                }
                else
                {
                    var listId   = cardHistory.Movements[i + 1].FromListId;
                    var duration = cardHistory.Movements[i + 1].Date.Subtract(cardHistory.Movements[i].Date);
                    AddDuration(result, listId, duration);
                }
            }
            return(result);
        }