Skip to content

Instantly share code, notes, and snippets.

@Hkazanci93
Created March 29, 2022 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hkazanci93/7419d05c67af51fa94b674f5f0c29526 to your computer and use it in GitHub Desktop.
Save Hkazanci93/7419d05c67af51fa94b674f5f0c29526 to your computer and use it in GitHub Desktop.
String biggestSpendersKey = SORTED_SET_KEY + principal.getName();
Set<TypedTuple<String>> range = redis.opsForZSet().rangeByScoreWithScores(biggestSpendersKey, 0,
Double.MAX_VALUE);
if (range.size() > 0) {
BiggestSpenders biggestSpenders = new BiggestSpenders(range.size());
int i = 0;
for (TypedTuple<String> typedTuple : range) {
biggestSpenders.getSeries()[i] = Math.floor(typedTuple.getScore() * 100) / 100;
biggestSpenders.getLabels()[i] = typedTuple.getValue();
i++;
}
return biggestSpenders;
} else {
return new BiggestSpenders(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment