try restore updated date

ref #386
This commit is contained in:
collinbarrett 2018-08-31 13:15:40 -05:00
parent dd0542d468
commit d937bd0fd8
4 changed files with 39 additions and 21 deletions

View file

@ -23,7 +23,16 @@ public ListDetailsDtoMappingProfile() =>
.SnapshotRules
.Count
: 0))
.ForMember(d => d.UpdatedDate, o => o.MapFrom(l => l.ModifiedDateUtc))
.ForMember(d => d.UpdatedDate,
o => o.MapFrom(l =>
l.Snapshots
.Count(s => s.WasSuccessful && s.Md5Checksum != null) >= 2
? l.Snapshots
.Where(s => s.WasSuccessful && s.Md5Checksum != null)
.Select(s => s.CreatedDateUtc)
.OrderByDescending(c => c)
.FirstOrDefault()
: null))
.ForMember(d => d.ViewUrl,
o => o.MapFrom(l =>
l.Snapshots

View file

@ -12,7 +12,16 @@ public ListSummaryDtoMappingProfile() =>
CreateMap<Data.Entities.FilterList, ListSummaryDto>()
.ForMember(d => d.Languages, o => o.MapFrom(l => l.FilterListLanguages.Select(la => la.Language)))
.ForMember(d => d.Tags, o => o.MapFrom(l => l.FilterListTags.Select(m => m.Tag)))
.ForMember(d => d.UpdatedDate, o => o.MapFrom(l => l.ModifiedDateUtc))
.ForMember(d => d.UpdatedDate,
o => o.MapFrom(l =>
l.Snapshots
.Count(s => s.WasSuccessful && s.Md5Checksum != null) >= 2
? l.Snapshots
.Where(s => s.WasSuccessful && s.Md5Checksum != null)
.Select(s => s.CreatedDateUtc)
.OrderByDescending(c => c)
.FirstOrDefault()
: null))
.ForMember(d => d.ViewUrl,
o => o.MapFrom(l =>
l.Snapshots

View file

@ -122,22 +122,22 @@ export class Home extends React.Component<RouteComponentProps<{}>, IHomeState> {
headerClassName: "d-none d-md-block",
className: "d-none d-md-block"
},
//{
// Header: "Updated",
// accessor: "updatedDate",
// filterable: true,
// filterMethod: (filter: any, row: any) => row[filter.id].includes(filter.value),
// sortMethod: (a: any, b: any) => moment(a).isValid()
// ? (moment(b).isValid() ? (moment(a).isBefore(b) ? -1 : 1) : 1)
// : -1,
// Cell: (cell: any) => <div>{moment(cell.value).isValid()
// ? moment(cell.value).format("l")
// : "N/A"}</div>,
// style: { whiteSpace: "inherit" },
// width: 100,
// headerClassName: "d-none d-md-block",
// className: "d-none d-md-block"
//},
{
Header: "Updated",
accessor: "updatedDate",
filterable: true,
filterMethod: (filter: any, row: any) => row[filter.id].includes(filter.value),
sortMethod: (a: any, b: any) => moment(a).isValid()
? (moment(b).isValid() ? (moment(a).isBefore(b) ? -1 : 1) : 1)
: -1,
Cell: (cell: any) => <div>{moment(cell.value).isValid()
? moment(cell.value).fromNow()
: "N/A"}</div>,
style: { whiteSpace: "inherit" },
width: 100,
headerClassName: "d-none d-md-block",
className: "d-none d-md-block"
},
{
Header: "Details",
accessor: "id",

View file

@ -66,7 +66,7 @@ function ListInfo(props: any) {
<Languages languages={props.details.languages}/>
<RuleCount count={props.details.ruleCount}/>
<DiscontinuedDate date={props.details.discontinuedDate}/>
{ /* <UpdatedDate date={props.details.updatedDate}/>--> */ }
<UpdatedDate date={props.details.updatedDate}/>
<PublishedDate date={props.details.publishedDate}/>
<License license={props.details.license}/>
</ul>
@ -141,8 +141,8 @@ function DiscontinuedDate(props: any) {
function UpdatedDate(props: any) {
return props.date
? <li className="list-group-item">
<p>Last Updated by Maintainer: {moment(props.date).format("l")}</p>
? <li className="d-md-none list-group-item">
<p>Last Updated: {moment(props.date).isValid() ? moment(props.date).fromNow() : "N/A"}</p>
</li>
: null;
}