-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/sort datasets #74
Changes from 3 commits
c459c8d
fb7f839
0515109
a318f2c
d1b6fd5
0c2249a
c33d185
df094b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { | |
MITOTIC_STAGE_KEY, | ||
PROTEIN_NAME_KEY, | ||
} from "../../constants"; | ||
import { DatasetMetaData } from "../../constants/datasets"; | ||
import { State } from "../types"; | ||
|
||
import { | ||
|
@@ -28,6 +29,31 @@ export const getMeasuredFeaturesDefs = (state: State) => state.metadata.measured | |
export const getFileInfo = (state: State) => state.metadata.cellFileInfo; | ||
export const getClusterData = (state: State) => state.metadata.clusterData; | ||
|
||
export const getDatasetsByNewest = createSelector([getDatasets], (datasets) => { | ||
return datasets.sort((a: DatasetMetaData, b: DatasetMetaData) => { | ||
// TODO: We need to sort and group datasets by "megasets" | ||
// and then order those megasets by "newness" | ||
// plus we have plans to have different versions of the same | ||
// dataset contained within one card, so this is a temporary | ||
// sort function to get the newest datasets on top | ||
if (a.name === b.name) { | ||
// if it's the same dataset, return the newest version first | ||
if (a.version > b.version) { | ||
return -1; | ||
} else { | ||
return 1; | ||
} | ||
// otherwise sort by name | ||
} else if (a.name > b.name){ | ||
return -1; | ||
} else if (a.name < b.name) { | ||
return 1; | ||
} else { | ||
return 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sorting function has always been kinda confusing for me, but is it possible to just write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, so i've updated it based on Dan's comment, but you're right, I am now comparing numbers so I could just subtract them instead of doing a comparison, that will reduce the number of checks I have to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I miss read this comment a bit. For string comparisons you can't subtract them, this comparison is a pseudo alphabetical sort, mostly I just want the same names grouped together. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the sort function, let me know what you think |
||
} | ||
}); | ||
}) | ||
|
||
export const getMeasuredFeatureArrays = createSelector([getPerCellDataForPlot], (dataForPlot: DataForPlot) => { | ||
return dataForPlot.values; | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because version numbers are strings and can be SemVer or CalVer or whateVer, we are probably going to need some better way of doing this comparison. For example, does
2021.10
vs2021.1
break this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it would, i can fix that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any great ideas for this except for keeping an internal autoincremented single integer... or having the data creators specify what ordering they want. We rely on the data creators to consistently enforce their own preferred versioning scheme... I guess you could split on "." and hope for the best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't think this PR will cover all cases, it's even only ordering the correct dataset group first because it's just reversed alphabetized. Firebase does have time stamps too, so we could keep them ordered by last updated, however, that only works once we have more concrete ways of grouping mega sets together and grouping versions of the same name into one card