Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 9, 2022
1 parent 5a070dc commit 56d5efa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/history/data/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ import { shortenId } from '../merge/id.js'

// Retrieve filename from a rawResult
export const getRawResultFilename = function (rawResult) {
const { id, subId, timestamp } = rawResult
return serializeFilename({ id, subId, timestamp })
const metadatum = rawResultToMetadatum(rawResult)
return serializeFilename(metadatum)
}

const rawResultToMetadatum = function ({ id, subId, timestamp }) {
const idA = shortenId(id)
return { id: idA, subId, timestamp }
}

// Retrieve filename from a metadatum
export const serializeFilename = function ({ id, subId, timestamp }) {
const idStr = shortenId(id)
const timestampStr = serializeTimestamp(timestamp)
return `${timestampStr}_${idStr}_${subId}.json`
return `${timestampStr}_${id}_${subId}.json`
}

const serializeTimestamp = function (timestamp) {
Expand Down

0 comments on commit 56d5efa

Please sign in to comment.