public Repository(string name, string description, long forkCount, string ownerLogin, string ownerAvatarUrl, long issuesCount, string url, bool isFork, DateTimeOffset dataDownloadedAt, bool?isFavorite = null, IList <DailyViewsModel>?views = null, IList <DailyClonesModel>?clones = null, IEnumerable <DateTimeOffset>?starredAt = null) { IsFavorite = isFavorite; DataDownloadedAt = dataDownloadedAt; StarredAt = (starredAt?.OrderBy(x => x) ?? Enumerable.Empty <DateTimeOffset>()).ToList(); StarCount = StarredAt.Count; Name = name; Description = description; ForkCount = forkCount; OwnerLogin = ownerLogin; OwnerAvatarUrl = ownerAvatarUrl; IssuesCount = issuesCount; Url = url; IsFork = isFork; if (views != null && clones != null) { AddMissingDates(views, clones); } DailyViewsList = (views ?? Enumerable.Empty <DailyViewsModel>()).ToList(); DailyClonesList = (clones ?? Enumerable.Empty <DailyClonesModel>()).ToList(); TotalViews = DailyViewsList.Sum(x => x.TotalViews); TotalUniqueViews = DailyViewsList.Sum(x => x.TotalUniqueViews); TotalClones = DailyClonesList.Sum(x => x.TotalClones); TotalUniqueClones = DailyClonesList.Sum(x => x.TotalUniqueClones); IsTrending = (DailyViewsList.IsTrending() ?? false) || (DailyClonesList.IsTrending() ?? false); }
public Repository(string name, string description, long forkCount, RepositoryOwner owner, IssuesConnection?issues, string url, StarGazers stargazers, bool isFork, IList <DailyViewsModel>?views = null, IList <DailyClonesModel>?clones = null) { DataDownloadedAt = DateTimeOffset.UtcNow; Name = name; Description = description; ForkCount = forkCount; OwnerLogin = owner.Login; OwnerAvatarUrl = owner.AvatarUrl; IssuesCount = issues?.IssuesCount ?? 0; Url = url; StarCount = stargazers.TotalCount; IsFork = isFork; if (views != null && clones != null) { AddMissingDates(views, clones); } DailyViewsList = (views ?? Enumerable.Empty <DailyViewsModel>()).ToList(); DailyClonesList = (clones ?? Enumerable.Empty <DailyClonesModel>()).ToList(); TotalViews = DailyViewsList.Sum(x => x.TotalViews); TotalUniqueViews = DailyViewsList.Sum(x => x.TotalUniqueViews); TotalClones = DailyClonesList.Sum(x => x.TotalClones); TotalUniqueClones = DailyClonesList.Sum(x => x.TotalUniqueClones); var(isViewsTrending, isClonesTrending) = TrendingService.IsTrending(this); IsTrending = (isViewsTrending ?? false) || (isClonesTrending ?? false); }