BaGet.Core.DatabaseSearchService.FindDependentsAsync C# (CSharp) Method

FindDependentsAsync() public method

public FindDependentsAsync ( string packageId, CancellationToken cancellationToken ) : Task
packageId string
cancellationToken CancellationToken
return Task
        public async Task<DependentsResponse> FindDependentsAsync(string packageId, CancellationToken cancellationToken)
        {
            var dependents = await _context
                .Packages
                .Where(p => p.Listed)
                .OrderByDescending(p => p.Downloads)
                .Where(p => p.Dependencies.Any(d => d.Id == packageId))
                .Take(20)
                .Select(r => new PackageDependent
                {
                    Id = r.Id,
                    Description = r.Description,
                    TotalDownloads = r.Downloads
                })
                .Distinct()
                .ToListAsync(cancellationToken);

            return _searchBuilder.BuildDependents(dependents);
        }