mirror of
https://github.com/PretendoNetwork/super-mario-maker.git
synced 2026-08-02 00:15:36 -05:00
Total user uploads now shows
This commit is contained in:
parent
b2e4af46c2
commit
b37d2aa284
19
database.go
19
database.go
|
|
@ -328,6 +328,25 @@ func getCourseMetadataByDataIDs(dataIDs []uint64) []*CourseMetadata {
|
|||
return courseMetadatas
|
||||
}
|
||||
|
||||
func getCourseMetadatasByPID(pid uint32) []*CourseMetadata {
|
||||
courseMetadatas := make([]*CourseMetadata, 0)
|
||||
|
||||
// TODO: Fix this query? Seems like a weird way of doing this...
|
||||
var sliceMap []map[string]interface{}
|
||||
var err error
|
||||
|
||||
if sliceMap, err = cassandraClusterSession.Query(`SELECT data_id FROM pretendo_smm.courses WHERE owner_pid=? ALLOW FILTERING`, pid).Iter().SliceMap(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, course := range sliceMap {
|
||||
dataID := uint64(course["data_id"].(int64))
|
||||
courseMetadatas = append(courseMetadatas, getCourseMetadataByDataID(dataID))
|
||||
}
|
||||
|
||||
return courseMetadatas
|
||||
}
|
||||
|
||||
func insertBufferQueueData(dataID uint64, slot uint32, buffer []byte) {
|
||||
if err := cassandraClusterSession.Query(`INSERT INTO pretendo_smm.buffer_queues( id, data_id, slot, buffer ) VALUES ( now(), ?, ?, ? ) IF NOT EXISTS`, dataID, slot, buffer).Exec(); err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,114 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
func followingsLatestCourseSearchObject(err error, client *nex.Client, callID uint32, dataStoreSearchParam *nexproto.DataStoreSearchParam, extraData []string) {
|
||||
pRankingResults := make([]*nexproto.DataStoreCustomRankingResult, 0)
|
||||
|
||||
for _, pid := range dataStoreSearchParam.OwnerIds {
|
||||
courseMetadatas := getCourseMetadatasByPID(pid)
|
||||
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
now := uint64(time.Now().Unix())
|
||||
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // unknown
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // unknown
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // unknown
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.Tags = []string{""} // unknown
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = int64(courseMetadata.Attempts)
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[1].Slot = 1
|
||||
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.Count = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 2
|
||||
|
||||
// completions
|
||||
rankingResult.MetaInfo.Ratings[2].Slot = 2
|
||||
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = int64(courseMetadata.Completions)
|
||||
|
||||
// failures
|
||||
rankingResult.MetaInfo.Ratings[3].Slot = 3
|
||||
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = int64(courseMetadata.Failures)
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[4].Slot = 4
|
||||
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.Count = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 5
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[5].Slot = 5
|
||||
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.Count = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 6
|
||||
|
||||
// Number of new Miiverse comments
|
||||
rankingResult.MetaInfo.Ratings[6].Slot = 6
|
||||
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 0
|
||||
|
||||
pRankingResults = append(pRankingResults, rankingResult)
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(nexServer)
|
||||
|
||||
// TODO complete this
|
||||
// rankingResults = make([]*nexproto.DataStoreCustomRankingResult, 0)
|
||||
|
||||
rmcResponseStream.WriteUInt32LE(0x00000000) // pRankingResults List length 0
|
||||
rmcResponseStream.WriteListStructure(pRankingResults)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user