zepinos / leaderboard Goto Github PK
View Code? Open in Web Editor NEWzepinos leaderboard with redis, spring boot
License: Apache License 2.0
zepinos leaderboard with redis, spring boot
License: Apache License 2.0
Hi,
I've used http://localhost:8080/admin/createLeaderboardInfo?name=Ashu&period=DAY&sort=DESC
to create multiple rows.
Then I used http://localhost:8080/leaderboard/appendScore?position=4&userId=4&score=6
to append score and user id.
And finally using http://localhost:8080/admin/listLeaderboardInfo?startPosition=0&endPosition=99
I expect the result of this api to be sorted based on score, but it's not sorting based on score.
It is simply returning in order of key's position !
So it's not really a leader-board !!
Also, I can see this :
if (epochHashOperations.hasKey(currentEpochKey, userId)) {
// TODO 마지막으로 점수를 저장한 timestamp 을 가져와 ZSet 에서 사용자의 등록된 점수 조회
Long currentEpoch = epochHashOperations.get(currentEpochKey, userId);
Double currentScore = zSetOperations.score(currentKey, currentEpoch + ":" + userId);
if ((sort == Sort.ASC && currentScore.doubleValue() < score) ||
(sort == Sort.DESC && currentScore > score)) {
// TODO 현재 timestamp 와 점수를 저장
}
} else {
// TODO 등록된 정보가 없다면 최초 등록이기 때문에 무조건 등록
}
So main logic is for us //TODO !
And you haven't even used ZSET, but just kept it in comment.
So, this isn't very helpful, as it's not behaving like leader-board !
See, I've given different scores so the list should be sorted based on score, but see the output, it is not sorted based on score, but it is just appearing based on position.
http://localhost:8080/admin/listLeaderboardInfo?startPosition=0&endPosition=99
{
"leaderboardInfoList": [
{
"name": "MyLeaderBoard001",
"period": "DAY",
"sort": "DESC",
"status": "USE"
},
{
"name": "MyLeaderBoard002",
"period": "DAY",
"sort": "DESC",
"status": "USE"
},
{
"name": "MyLeaderBoard003",
"period": "DAY",
"sort": "DESC",
"status": "USE"
},
{
"name": "Abhishek",
"period": "DAY",
"sort": "DESC",
"status": "USE"
},
{
"name": "Ashu",
"period": "DAY",
"sort": "DESC",
"status": "USE"
}
],
"status": 0
}
Here, score of Abhishek is highest, then my score, and leaderboard001, 2, 3 are also in different score !
So, please let me know asap, if I'm doing something wrong, or you haven't really implemented entire leaderboard.
Thanks and Regards,
Ashutosh Pathak
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.