Sort Gist files by user-defined sort order#1891
Conversation
This will sort the files in an exported Gist by the user-defined sort
order. It does so by prefixing the files with `result-{index}-` where
the `index` is the 1-based index of the repository in the sort order.
It will automatically pad the index with leading zeros to ensure that
the files are sorted in the correct order.
Unfortunately, we can't just use `{index}-` because numbers sort before
the `_` character, which is used in the summary filename to place it
first.
There are also some changes in how we determine which repositories to
export since we need to know in advance how many zeroes we need to pad
the index with. There should be no functional changes in which
repositories are actually exported.
robertbrignull
left a comment
There was a problem hiding this comment.
LGTM
I agree this should have no effect on behaviour. We were previously yielding repos with no results but then they got filtered out later. Now those repos are filtered out earlier in the process.
| repoStates.find((r) => r.repositoryId === repo.repository.id) | ||
| ?.downloadStatus === | ||
| VariantAnalysisScannedRepositoryDownloadStatus.Succeeded, | ||
| ); |
There was a problem hiding this comment.
Could we incorporate the extra array pass into the original filtering, perhaps in a separate new function (e.g. filterSuccessfulReposWithResults)?
There was a problem hiding this comment.
I think that would be really specific to this use-case (especially with the repoStates being in a different array), so I think this wouldn't be clearer if we split it out into a separate function which is only used once and depends on some specific input.
There was a problem hiding this comment.
It's quite long to parse when you're trying to work out what it's doing, so I was mostly looking for some sort of way to make it easy to read the next time we come to it. But it's not a blocking issue.
This will sort the files in an exported Gist by the user-defined sort order. It does so by prefixing the files with
result-{index}-where theindexis the 1-based index of the repository in the sort order. It will automatically pad the index with leading zeros to ensure that the files are sorted in the correct order.Unfortunately, we can't just use
{index}-because numbers sort before the_character, which is used in the summary filename to place it first.There are also some changes in how we determine which repositories to export since we need to know in advance how many zeroes we need to pad the index with. There should be no functional changes in which repositories are actually exported.
Checklist
ready-for-doc-reviewlabel there.