public IssuesSummaries GetSummaries(IssueFilter filter) { CheckAccess(); Thread.Sleep(300); var issues = (IEnumerable <IssueData>)AllIssues.Value; if (filter != null) { issues = FilterIssues(filter, issues); } var lastCreated = issues.Any() ? issues.Max(x => x.Created) : default(DateTime?); return(new IssuesSummaries(count: issues.Count(), lastCreated: lastCreated)); }
static FetchRowsResult FetchRows(FetchRowsEventArgs e) { IssueSortOrder sortOrder = GetIssueSortOrder(e); IssueFilter filter = MakeIssueFilter(e.Filter); var issuesContext = (IssuesContext)e.Source; const int pageSize = 30; var issues = issuesContext.GetIssues( page: e.Skip / pageSize, pageSize: pageSize, sortOrder: sortOrder, filter: filter); return(new FetchRowsResult(issues, hasMoreRows: issues.Length == pageSize)); }
static object[] GetTotalSummaries(GetSummariesEventArgs e) { IssueFilter filter = MakeIssueFilter(e.Filter); var issuesContext = (IssuesContext)e.Source; var summaryValues = issuesContext.GetSummaries(filter); return(e.Summaries.Select(x => { if (x.SummaryType == SummaryType.Count) { return (object)summaryValues.Count; } if (x.SummaryType == SummaryType.Max && x.PropertyName == "Created") { return summaryValues.LastCreated; } throw new InvalidOperationException(); }).ToArray()); }
static IEnumerable <IssueData> FilterIssues(IssueFilter filter, IEnumerable <IssueData> issues) { if (filter.CreatedFrom != null || filter.CreatedTo != null) { if (filter.CreatedFrom == null || filter.CreatedTo == null) { throw new InvalidOperationException(); } issues = issues.Where(x => x.Created >= filter.CreatedFrom.Value && x.Created < filter.CreatedTo); } if (filter.MinVotes != null) { issues = issues.Where(x => x.Votes >= filter.MinVotes.Value); } if (filter.Priority != null) { issues = issues.Where(x => x.Priority == filter.Priority); } return(issues); }
public IssueData[] GetIssues(int page, int pageSize, IssueSortOrder sortOrder, IssueFilter filter) { CheckAccess(); Thread.Sleep(300); var issues = SortIssues(sortOrder, AllIssues.Value); if (filter != null) { issues = FilterIssues(filter, issues); } return(issues.Skip(page * pageSize).Take(pageSize).ToArray()); }