Esempio n. 1
0
        public async Task <IList <ChapterItemDto> > GetTableOfConents(string projectId, string branchName)
        {
            if (branchName == null || branchName == "undefined")
            {
                branchName = await GetDefaultBranch(projectId);
            }

            IList <ChapterItemDto> toc = null;

            if (!_cacheService.TryGetTableOfContents(projectId, branchName, out toc))
            {
                var branch = await _branchesClient.Get(projectId, branchName);

                if (branch != null)
                {
                    var mkDocsConfiguration = ReadMkDocsConfiguration(branch.MkDocsYaml);
                    toc = GetChapterItems(mkDocsConfiguration);

                    var cacheEntryOptions = new MemoryCacheEntryOptions()
                                            .SetSlidingExpiration(TimeSpan.FromMinutes(10));

                    _cacheService.AddTableOfContentsToCache(projectId, branchName, toc);
                }
            }

            return(toc);
        }
Esempio n. 2
0
        public async Task <IList <ExtendedBranchDto> > GetBranchesAsync(string projectId)
        {
            IList <ExtendedBranchDto> branches = null;

            if (!_cacheService.TryGetBranches(projectId, out branches))
            {
                var branchesDto = await _branchesClient.Get(projectId);

                if (branchesDto == null)
                {
                    return(null);
                }

                branches = branchesDto.Select(x => CreateExtendedBranchDto(x)).ToList();
                _cacheService.AddBranches(projectId, branches);
            }

            return(branches);
        }