Just quick introduction - this controller is used in the search facility that this website provides. It is linked to CouchDBManager and the Search page. There is no need to get into details about code here, main point is to explain what is doing what.
Summary: Gets a list with 20* jobs per page, matching the searching criteria in
/search form on the right pane. It also looks for current jobs, using
dateTimeFrom > DateTime.Now in the selector expression - that could be optional in future. Only LIVE jobs will be displayed, omitting the regional and internal bank ones. If the user has chosen and verified a post code, additional feature will be triggered, which is our location search. The latitude and longitude will be retrieved from the provided postscode by making an
ajax call to postcodes.io, after which that is passed along with the units and maximum distance to our method, which calls a separate one in CouchDBManager -
function Search() in
This method takes the following parameters:
The types of the params are very well described just above the method, similarly to every other method. The first three parameters (starting with
job_) are passing actual query strings and if there is more than one
grade selected, they will be separated with a comma. The
page_number param is self-explanatory. User
longitude provide the X and Y,
max_distance is the preferred distance and
distance_type can be miles by default or kilometres (foreigners 😂), if the user has chosen to fill in his post code.
This method takes the following parameter:
This method looks for a job containing the given
jobNumber and if it exists and the job matches certain requirements (specified in the selector expression), the Job Details page will be brought with information about that job.
20* Although there are shown 20 jobs per page, 21 items are queried. This is done to check if the
Next page button should be disabled. There are rare circumstances where this logic breaks, but still works most of the time, just like everything else.