Skip to content
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

Backend search constraints (length & whitespace) #630

Merged
merged 23 commits into from
May 30, 2019
Merged

Conversation

sashadev-sky
Copy link
Member

@sashadev-sky sashadev-sky commented May 23, 2019

References ##520 (comment) (<=== Add issue number here)

Note there is a PR open for this but that implementation was not working as expected originally and is also stale now so going to try to just solve the problem myself and close that one

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@codeclimate
Copy link

codeclimate bot commented May 23, 2019

Code Climate has analyzed commit 2c46a2bc and detected 0 issues on this pull request.

View more on Code Climate.

@sashadev-sky
Copy link
Member Author

@publiclab/reviewers

@codecov
Copy link

codecov bot commented May 23, 2019

Codecov Report

Merging #630 into main will increase coverage by <.01%.
The diff coverage is 79.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #630      +/-   ##
==========================================
+ Coverage   71.27%   71.27%   +<.01%     
==========================================
  Files          32       33       +1     
  Lines        1288     1295       +7     
==========================================
+ Hits          918      923       +5     
- Misses        370      372       +2
Impacted Files Coverage Δ
lib/not_at_origin_validator.rb 100% <100%> (ø)
app/controllers/maps_controller.rb 90.51% <69.23%> (-3.12%) ⬇️
app/models/map.rb 85.52% <80%> (+0.81%) ⬆️

Copy link
Member

@grvsachdeva grvsachdeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!! I noticed that in issue and in #535 we have also talked about not allowing the search of blank spaces. I would reframe that proposal -- Do you think, we should allow the search term to be a combination of letters and numbers only?

Thanks!

@sashadev-sky
Copy link
Member Author

@gauravano I was going to do this in a follow-up PR - got a little lazy here. It's not that much work so I will just implement it here and mention you for another review. Otherwise this should have been an FTO so I feel bad

@sashadev-sky sashadev-sky force-pushed the sashadev-sky-patch-4 branch from 2c46a2b to 0217483 Compare May 27, 2019 00:23
app/models/map.rb Outdated Show resolved Hide resolved
app/models/map.rb Outdated Show resolved Hide resolved
app/models/map.rb Outdated Show resolved Hide resolved
app/models/map.rb Outdated Show resolved Hide resolved
app/models/map.rb Outdated Show resolved Hide resolved
@sashadev-sky sashadev-sky changed the title Set minlength on search bar Backend search constraints (length & whitespace) May 27, 2019
@grvsachdeva
Copy link
Member

grvsachdeva commented May 28, 2019

No issues. Let me know when you're done or need help. Thank you!

@sashadev-sky
Copy link
Member Author

sashadev-sky commented May 29, 2019

@gauravano ok this is ready. this is a backend implementation that imposes a 3 character limit, not including spaces. So it allows the person to type spaces and submit them and it trims left and right whitespace and extra white space between words so you can search for a map named "new york" like

"  new     york    "
and itll still find it.

But it doesn't include spaces in the character count so if you tried to search "nn " it would impose the character count on you.

Also does not allow for blank search.

Any further restrictions and some optimizations should be a follow up on the front-end.

I also did a lot of refactoring of map.rb but the main driver behind this code is in the search action in maps controller

let me know if its good to go! Thanks :)

@jywarren
Copy link
Member

Oops, i merged your header fix and now I think it created a conflict here! Sorry!

@sashadev-sky sashadev-sky force-pushed the sashadev-sky-patch-4 branch from cf1015a to d4d991e Compare May 30, 2019 03:28
@sashadev-sky
Copy link
Member Author

@jywarren rebased!

@jywarren jywarren merged commit 6c79669 into main May 30, 2019
@jywarren
Copy link
Member

Super!!!

chen-robert pushed a commit to chen-robert/mapknitter that referenced this pull request Dec 5, 2019
* refactor search

* delete commented lines

* resolve code climate

* add flash notice

* use request.referrer to reference last page

* fix rubocop

* refactorings

* fix rubocop

* more refactorings

* fix more rubocop

* squeeze center whitespace

* strip leading and trailing whitespace

* refactor map.rb to  fix rubocop class over 250 lines

* fix offences

* fix cops

* offence fix

* fix last robocop

* fix cop

* cop

* fix redundant self

* remove redunant self pt2

* undo new asset path

* tag fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants