-
Notifications
You must be signed in to change notification settings - Fork 406
#RI-3612-zset infinity score #1285
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
Conversation
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.
Bakend looks good. I've added few comments. It will be nice to address them but not necessary in case if we must move forward asap.
} | ||
|
||
defaultMessage(args: ValidationArguments) { | ||
return `${args.property || 'field'} must be a string or a number`; |
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.
must be a string? "hello world" will be not a valid value here...
BrowserToolZSetCommands.ZScore, | ||
[keyName, member], | ||
); | ||
const formattedScore = isNaN(parseFloat(score)) ? String(score) : parseFloat(score); |
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.
Can we move this to some function to not duplicate logic everywhere?
while (reply.length) { | ||
const member = reply.splice(0, 2); | ||
const score = isNaN(parseFloat(member[1])) ? String(member[1]) : parseFloat(member[1]); | ||
result.push(plainToClass(ZSetMemberDto, { |
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.
we are using "plainToClass" here. Maybe it is better to create own transformer and isNaN(parseFloat(member[1])) ? String(member[1]) : parseFloat(member[1]);
will be done automatically inside?
P.S. See comment above
name: Joi.string().required(), | ||
// todo: allow(true) - is incorrect but will be transformed to number by BE. Investigate/fix it | ||
score: Joi.number().required().allow(true), | ||
score: Joi.number().required().allow('inf', '-inf').label('.score'), |
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.
it is better to create own type here the same way as for redisString
so it will look like Joi.zSetScore().required()
or something similar
members: Joi.array().items(Joi.object().keys({ | ||
name: JoiRedisString.required(), | ||
score: Joi.number().required(), | ||
score: Joi.number().required().allow('inf', '-inf'), |
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.
the same
members: Joi.array().items(Joi.object().keys({ | ||
name: JoiRedisString.required(), | ||
score: Joi.number().required(), | ||
score: Joi.number().required().allow('inf', '-inf'), |
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.
the same
@Type(() => Number) | ||
score: number; | ||
@isZSetScore() | ||
score: number | 'inf' | '-inf'; |
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.
It is better to create a type (like type ZSetScore = ...
) and use it everywhere
No description provided.