public static Project FromHudsonAPI(HudsonFreeStyleProjectResponse response, BuildJob lastbuild, BuildJob successfulbuild, BuildJob completedbuild, BuildJob currentbuild, IEnumerable<Project> upstreamProjects, IEnumerable<Project> downstreamProjects, ProjectBuildQueue queue)
        {
            var projectname = response.Name;

            var progress = 0;
            if (currentbuild.IsBuilding)
                progress = GetPercentageProgress(currentbuild.Timestamp, successfulbuild.Duration);

            var position = queue.Items.ToList().FindIndex(x => x.Name == projectname) + 1;

            return new Project(projectname, lastbuild, successfulbuild, completedbuild, currentbuild, progress, position, upstreamProjects, downstreamProjects);
        }
        public ProjectBuildQueue GetQueue()
        {
            if (_cachedQueue != null) return _cachedQueue;

            var request = new HudsonQueueRequest();

            var response = QueueRepository.Get(request);
            var projectBuildQueue = response.Items
                                                                            .Where(build => build.Task != null)
                                                                            .Select(build => GetProject(build.Task.Name));

            _cachedQueue = ProjectBuildQueueMapper.FromHudsonAPI(projectBuildQueue);

            return _cachedQueue;
        }