-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Allow decimals in the local alert radius. #5205
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5205 +/- ##
=======================================
Coverage 82.34% 82.34%
=======================================
Files 409 409
Lines 31999 32002 +3
Branches 5096 5096
=======================================
+ Hits 26349 26352 +3
+ Misses 4149 4148 -1
- Partials 1501 1502 +1 ☔ View full report in Codecov by Sentry. |
$distance = 150 if $distance > 150; # Match Gaze maximum | ||
return $distance; | ||
return $distance + 0; |
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.
Why is the + 0 needed?
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.
To make sure it is internally a number, not a string of 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.
I guess in my experience, Perl just 'does the right thing' and treats it as a string or a number based on the context. Was there a specific instance where not having it explicitly be a number was causing bugs?
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.
Yes, it does do that, but in a non-English locale a decimal number could eg stringify with a comma, not a point. I know we call in_gb_locale
above, but if the input is already converted to a string before that point (with a comma), that call won't change anything, it's already a string. So we need to make sure it's a number before it gets there.
I'm not sure it /actually/ matters here, there's no use locale
but I think that can have spooky action at a distance so better to be safe.
@@ -111,7 +111,7 @@ sub local_problems_pc_distance : Path('pc') : Args(2) { | |||
|
|||
} | |||
|
|||
sub local_problems_dist : LocalRegex('^(n|l)/([\d.-]+)[,/]([\d.-]+)/(\d+)$') { | |||
sub local_problems_dist : LocalRegex('^(n|l)/([\d.-]+)[,/]([\d.-]+)/(\d+(?:\.\d+)?)$') { |
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 regex here checks for a full stop, but in get_distance in the file above, it also checks for a comma. Why is there not one here?
Also, where is local_problems_dist called from?
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.
Yes, get_distance allows people to enter decimals as commas, but then it's always a decimal point by the time it reaches the URL (and then here).
RSS feeds of that form come here directly, it's a controller, so not called from anywhere. The Alert page will construct an RSS in this form if you supplied a distance there.
$distance = 150 if $distance > 150; # Match Gaze maximum | ||
return $distance; | ||
return $distance + 0; |
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.
I guess in my experience, Perl just 'does the right thing' and treats it as a string or a number based on the context. Was there a specific instance where not having it explicitly be a number was causing bugs?
Fixes https://github.com/mysociety/societyworks/issues/3278