-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: STUD-366: Update GetSongs endpoint to sort earnings #587
feat: STUD-366: Update GetSongs endpoint to sort earnings #587
Conversation
@@ -1154,7 +1154,8 @@ class LedgerRepositoryImpl : LedgerRepository { | |||
(AddressTxLogTable.id greater afterId) and | |||
(AddressTxLogTable.blockNumber lessEq maxBlockNumber) | |||
}.orderBy(AddressTxLogTable.id) | |||
.limit(limit, offset) |
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.
This function is now deprecated in exposed. It actually contains a bug. Internally, it applies limit first and then offset. The ordering is very important to these two functions. offset MUST be applied before limit. If you have a list of 10 items and apply limit 5, offset 5, it will return you an empty list instead of the second 5 items of the original list.
@@ -69,7 +76,18 @@ fun Routing.createSongRoutes() { | |||
}.sumOf { it.amount } | |||
song.copy(earnings = allEarningsAmount) | |||
} | |||
respond(songsAndEarnings) | |||
if (songFilters.sortedBy == "earnings") { |
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.
This is the meat of the PR. The rest is the major exposed update. I attempted to update KTOR at the same time to version 3, but we need to wait until Koin supports that version of KTOR.
@@ -149,7 +147,6 @@ class SongEntity( | |||
|
|||
fun genres(filters: SongFilters): SizedIterable<String> { | |||
val ops = filters.toOps() | |||
val genre = SongTable.genres.unnest() |
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 couldn't get our unnest()
to work with the new Array support in exposed. I took the approach of just pulling all the data down and manipulating it in the kotlin code.
|
||
/** | ||
* Invokes the `ANY` function on an expression. | ||
*/ | ||
@JvmName("any") | ||
fun <T> ExpressionWithColumnType<Array<T>>.any(): ExpressionWithColumnType<T> = anyFunc() | ||
fun <T> ExpressionWithColumnType<List<T>>.any(): ExpressionWithColumnType<List<T>> = anyFunc() |
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'm unsure if any of these work beyond the overlaps
function. I think they are all unused as of now. The modifications are mostly to get the code to compile. If you use any of them, please test to make sure they work properly.
No description provided.