mirror of
https://github.com/PretendoNetwork/super-mario-maker.git
synced 2026-04-24 15:27:16 -05:00
Merge 12deaca1cf into bb1f927fd6
This commit is contained in:
commit
33550699ba
|
|
@ -1,7 +1,6 @@
|
|||
package datastore_smm_db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
|
|
@ -35,26 +34,22 @@ func GetRandomCoursesWithLimit(limit int) (types.List[datastore_super_mario_make
|
|||
object.tags,
|
||||
object.creation_date,
|
||||
object.update_date,
|
||||
ranking.value
|
||||
COALESCE(ranking.value, 0)
|
||||
FROM datastore.objects object
|
||||
JOIN datastore.object_custom_rankings ranking
|
||||
LEFT JOIN datastore.object_custom_rankings ranking
|
||||
ON
|
||||
object.data_id = ranking.data_id AND
|
||||
ranking.application_id = 0
|
||||
WHERE
|
||||
object.upload_completed = TRUE AND
|
||||
object.deleted = FALSE AND
|
||||
object.under_review = FALSE AND
|
||||
ranking.application_id = 0
|
||||
object.under_review = FALSE
|
||||
ORDER BY RANDOM()
|
||||
LIMIT $1
|
||||
`, limit)
|
||||
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nex.NewError(nex.ResultCodes.DataStore.NotFound, "Object not found")
|
||||
}
|
||||
|
||||
globals.Logger.Error(err.Error())
|
||||
// TODO - Send more specific errors?
|
||||
return nil, nex.NewError(nex.ResultCodes.DataStore.Unknown, err.Error())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,14 @@ func CTRPickUpCourseSearchObject(err error, packet nex.PacketInterface, callID u
|
|||
|
||||
// TODO - Research extraData
|
||||
// TODO - Use the offet? Real client never uses it, but might be nice for completeness sake?
|
||||
pRankingResults, nexError := datastore_smm_db.GetRandomCoursesWithLimit(int(param.ResultRange.Length))
|
||||
length := int(param.ResultRange.Length)
|
||||
maxLength := 25
|
||||
if length <= 0 || length > maxLength {
|
||||
globals.Logger.Warningf("Limiting request to %d courses (was %d)", maxLength, length)
|
||||
length = maxLength
|
||||
}
|
||||
|
||||
pRankingResults, nexError := datastore_smm_db.GetRandomCoursesWithLimit(length)
|
||||
if nexError != nil {
|
||||
return nil, nexError
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user