Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/adminPage/adminSnapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async function manageSnapshots(snapshotTable) {
snapshotTable.appendChild(snapshotsUL)

sortedSnapshotFileNames.reverse(function (x, y) {
const timestampx = x.substring(x.lastIndexOf('-')+1, x.indexOf('.ttl'))
const timestampy = y.substring(y.lastIndexOf('-')+1, y.indexOf('.ttl'))
const timestampx = getTimestampFromSnapshot(x)
const timestampy = getTimestampFromSnapshot(y)
return timestampx - timestampy;
})

Expand All @@ -39,7 +39,7 @@ async function manageSnapshots(snapshotTable) {

const timestampDiv = document.createElement('div')
timestampDiv.setAttribute('class', 'timstampDiv')
const timestamp = sortedSnapshotFileNames[i].substring(sortedSnapshotFileNames[i].lastIndexOf('-') + 1, sortedSnapshotFileNames[i].indexOf('.ttl'))
const timestamp = getTimestampFromSnapshot(sortedSnapshotFileNames[i])
timestampDiv.textContent = (new Date(parseInt(timestamp))).toISOString()

const userDiv = document.createElement('div')
Expand Down
8 changes: 6 additions & 2 deletions src/adminPage/snapshots/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async function createSnapshot(store, currentKG, nameOfSnapshot) {

function deleteOlderSnapshots(store, snapshots, threshold) {
snapshots.sort(function (x, y) {
const timestampx = x.substring(x.lastIndexOf('-')+1, x.indexOf('.ttl'))
const timestampy = y.substring(y.lastIndexOf('-')+1, y.indexOf('.ttl'))
const timestampx = getTimestampFromSnapshot(x)
const timestampy = getTimestampFromSnapshot(y)
return timestampx - timestampy;
})
for (let i = 0; i < snapshots.length-threshold; i++) {
Expand Down Expand Up @@ -109,4 +109,8 @@ async function getSnapshotWithoutAdditionalTriples(store, linkToResource) {
loadedResource = await store.fetcher.load(linkToResource)
await store.updater.update([], creator.concat(modified))
return loadedResource
}

function getTimestampFromSnapshot(snapshot) {
return snapshot.substring(snapshot.lastIndexOf('-')+1, snapshot.lastIndexOf('.'))
}