Order bulk extracts in API by date descending

This commit is contained in:
Maciej Ziarkowski 2020-01-21 12:37:14 +00:00
parent c0dcea61fe
commit f0e791297e
2 changed files with 3 additions and 5 deletions

View File

@ -19,7 +19,8 @@ async function listDataExtracts(): Promise<DataExtract[]> {
const extractRecords = await db.manyOrNone<DataExtractRow>(
`SELECT
extract_id, extracted_on, extract_path
FROM bulk_extracts`
FROM bulk_extracts
ORDER BY extracted_on DESC`
);
return extractRecords.map(getDataExtractFromRow);

View File

@ -30,10 +30,7 @@ export default class DataExtracts extends React.Component<{}, DataExtractsState>
async componentDidMount() {
let data = await apiGet('/api/extracts', { jsonReviver: dateReviver});
const extracts = (data.extracts as ExtractViewModel[])
.sort((a, b) => b.extracted_on.valueOf() - a.extracted_on.valueOf());
const extracts = (data.extracts as ExtractViewModel[]);
this.setState({ extracts: extracts, latestExtract: extracts[0], previousExtracts: extracts.slice(1) });
}