Skip to content

colinross/bean-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup:
This packge requires the PostGIS extension (ontop of postgres) to be installed on the host system. Please see http://postgis.net/install/ for more instructions.
The application will set up the database and the extension to be used.
Run `bin/setup` to install dependencies and setup the database.

Running the application:
 - Run `bin/rails server` to start a WEBBrick instance serving the application on port 3000.
 - Navigate to "http://http://localhost:3000/"  in your prefered web client (Safari, Chrome, etc.)

To run the test suite:
Run `rake db:test:prepare` then `rake`

Implementation Notes
 - I tried to both keep things light on the dependency side and only pull in what was needed. This included a few dev/test tools (pry, rspec, shoulda-matchers) and the packages required to utilize Postgres and the PostGIS extension. 'immutable-struct' was also pulled in as a helper library for easily making extendable structures for both richer return values form services, and also as a stand-in for hard-coded 'location'-like records (GPS_Location in the Locations Controller)
 - The index action supports both html and json formats. It also allows to pass in a custom 'origin' point for the listing. Origin is a GPS point in the common "latitude, longitude" format, for example http://localhost:3000/locations.json?origin=31.764845199999996, -115.19689439999999"
 - I used strong params as a poor mans basic check for the acceptance of user-supplied parameters. This means there is virtually no defensive checks for security and or user-friendliness. This was just a time-limiting decision.
 - As you might be able to tell from the timestmps, I worked on this over the course of a weekend in bits and pieces. I spent approximately 4.5 - 5 hours, much of which was refreshing myself on the syntax/symantics of postgres and learning about the basics of PostGIS, and getting postgres installed. While it was something I had seen some sample code from, this is my first time actually using it fully. My "normal" environment is vanilla mysql. I did spend a 20 minutes going down the rabbit hole of 'why is there no results' with some sample code I had [Previsouly, I was hoping to loop in a configurable 'max distance' functionality to the lookup.] Well Played.
 - One of the first questions one might ask about my implementation is "Why did you build a service?". Simply, the answer is that while the core requirement of the challenge doesn't require it [I could have easily just done it all in the controller/model for instance and saved on overhead], I have a firm conviction that you don't develop in a vacuum and that includes leveraging your experiences in order to predict and plan for future growth. There is a balance here to strike, avoiding premature complexity and premature optimizations in code, but I believe the slight overhead of making a service allowed the funcionality to be tested easier and made the code a LOT more readable and contextual. These decisions come down to bigger ones like 'do I make a service here' and smaller decisions, like accepting the file via a keyword argument that can be later made optional and then adding another, say, 'url', that would download the file at the given url before processing the import. Small things save big time and are worth the risk of a slight level of over complication.
 - I specifically did NOT rebase / squash my commits. I usually would honestly, but I thought the insight it gives into my process would help you better evaluate. I also usually don't develop directly on master LIKE A BOSS.

Known Limitations
 - There is no delete functionality (`rake db:reset` works well to reset after an upload)
 - There are no validations or rules on the created Loction records, other than requiring coordinates, this means the duplicates are not just possible, but plenty after multiple 'uploads' of the same data.
 - While there are tests, I stayed away from going overboard with full request specs (which is normally done for api-like endpoints)
 - There is little to no input validation (other than using strong params)
 - I was hoping to have time to make it pretty-- sorry. My front end skills, while present, aren't all that impressive, and integratiing something like material design / react would just take more time that I believe you guys wanted put into this. I could spend 16 hours on this, proving 'I work weekends if I need to'. I prefer if you just take my word for it.
 - I'm sure loads more: performance, validations, etc.

About

Code Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published