From 59f11adfc9435a66c8c15260bf23872808165b80 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 8 Jun 2018 11:01:39 -0500 Subject: [PATCH] add list updated date --- .../FilterList/FilterListService.cs | 15 +++++++++- .../FilterList/ListDetailsDto.cs | 1 + .../ClientApp/components/ListDetails.tsx | 28 +++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/FilterLists.Services/FilterList/FilterListService.cs b/src/FilterLists.Services/FilterList/FilterListService.cs index 0b8cca287..b642a0dae 100644 --- a/src/FilterLists.Services/FilterList/FilterListService.cs +++ b/src/FilterLists.Services/FilterList/FilterListService.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AutoMapper.QueryableExtensions; @@ -31,6 +32,7 @@ public async Task GetDetailsAsync(int id) .FirstAsync(x => x.Id == id) .FilterParentListFromMaintainerAdditionalLists(); details.RuleCount = await GetActiveRuleCount(details); + details.UpdatedDate = await GetUpdatedDate(details); return details; } @@ -45,5 +47,16 @@ await DbContext.Snapshots.Where(s => s.FilterListId == details.Id && s.IsComplet .SelectMany(sr => sr.RemovedSnapshotRules) .CountAsync(); } + + private async Task GetUpdatedDate(ListDetailsDto details) + { + return await DbContext.Snapshots.Where(s => s.FilterListId == details.Id && s.IsCompleted) + .Include(s => s.AddedSnapshotRules) + .Include(s => s.RemovedSnapshotRules) + .Where(s => s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0) + .Select(s => s.CreatedDateUtc) + .OrderByDescending(s => s.Date) + .FirstAsync(); + } } } \ No newline at end of file diff --git a/src/FilterLists.Services/FilterList/ListDetailsDto.cs b/src/FilterLists.Services/FilterList/ListDetailsDto.cs index 3fc956494..34ff86232 100644 --- a/src/FilterLists.Services/FilterList/ListDetailsDto.cs +++ b/src/FilterLists.Services/FilterList/ListDetailsDto.cs @@ -26,6 +26,7 @@ public class ListDetailsDto public int RuleCount { get; set; } public string SubmissionUrl { get; set; } public ListSyntaxDto Syntax { get; set; } + public DateTime? UpdatedDate { get; set; } public string ViewUrl { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Web/ClientApp/components/ListDetails.tsx b/src/FilterLists.Web/ClientApp/components/ListDetails.tsx index b21a84f32..fe0a148a5 100644 --- a/src/FilterLists.Web/ClientApp/components/ListDetails.tsx +++ b/src/FilterLists.Web/ClientApp/components/ListDetails.tsx @@ -55,8 +55,9 @@ function ListInfo(props: any) {
    - + +
; @@ -110,14 +111,6 @@ function RuleCount(props: any) { : null; } -function PublishedDate(props: any) { - return props.date - ?
  • -

    Published: {moment(props.date).format("MMM. D YYYY")}

    -
  • - : null; -} - function DiscontinuedDate(props: any) { return props.date ?
  • @@ -126,6 +119,22 @@ function DiscontinuedDate(props: any) { : null; } +function UpdatedDate(props: any) { + return props.date + ?
  • +

    Updated: {moment(props.date).format("MMM. D YYYY")}

    +
  • + : null; +} + +function PublishedDate(props: any) { + return props.date + ?
  • +

    Published: {moment(props.date).format("MMM. D YYYY")}

    +
  • + : null; +} + function License(props: any) { return props.license ? (props.license.descriptionUrl @@ -309,6 +318,7 @@ interface IFilterListDetailsDto { ruleCount: number; submissionUrl: string; syntax: IListSyntaxDto[]; + updatedDate: string; viewUrl: string; }