Skip to content

Commit

Permalink
Sort per-plot-type page by dataId.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctslater committed Dec 6, 2024
1 parent c4b33f4 commit 0b9b4a3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/plot/[repo]/[collection]/[plotName]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,23 @@ export default async function Collection({params, searchParams}) {

const collectionData = await GetSummary(repo, collection)

const plotEntries = findPlotEntries(collectionData, plotName)
const dataIdSortFunc = (a, b) => {
const dataIdA = JSON.parse(a.dataId)
const dataIdB = JSON.parse(b.dataId)
if('tract' in dataIdA && 'tract' in dataIdB) {
return dataIdA.tract - dataIdB.tract
} else if('visit' in dataIdA && 'visit' in dataIdB) {
return dataIdA.visit - dataIdB.visit
} else if('band' in dataIdA && 'band' in dataIdB) {
const bandsOrder = ['u', 'g', 'r', 'i', 'z', 'y']
return bandsOrder.indexOf(dataIdA.band) - bandsOrder.indexOf(dataIdB.band)
}
return 0
}

const plotEntries = findPlotEntries(collectionData, plotName).sort(dataIdSortFunc)

const encodeDataId = (id) => {
/* return encodeURIComponent(JSON.stringify(JSON.parse(id.trim()))) */
return encodeURIComponent(id.trim())
}

Expand Down

0 comments on commit 0b9b4a3

Please sign in to comment.