Giter VIP home page Giter VIP logo

homework's Introduction

= HomeWork

A test application which manage hosts, rooms and bookings.

==TASK

The purpose of this test is to build a simple Ruby on Rails application that allows to search for available rooms in host families.

There are 3 files containing data that must be imported into the system:

  • hosts-2000.csv

    List of host families defined by the following attributes:

    ref: Unique identifier for that host name: Name of the host address: Address of the host

  • rooms-2000.csv

    List of rooms for each one of the hosts, defined by the following attributes:

    ref: Unique identifier for the room host_ref: Identifier of the host the room belongs to capacity: Number of people that can sleep in the room

  • bookings-2000.csv

    List of bookings already made for the rooms, defined by:

    ref: Unique identifier for the booking room_ref: Identifier of the booked room start_date: Start date of the booking with format 'yyyy-mm-dd' end_date: End date of the booking with format 'yyyy-mm-dd' number_of_guests: Number of guests staying in the room for that booking

Deliver a Rails application including the following functionality:

  • Rake task to import the files hosts-2000.csv, rooms-2000.csv and bookings-2000.csv

  • Search the availability of hosts/rooms for a period with input fields:

    • Start date: day, month and year
    • End date: day, month and year
    • Number of guests: integer

    It should return a list of hosts which have rooms available for that period and that number of guests (in the same room), showing which rooms are available for that host and period and if those rooms already have any guests in any days within that period.

For example, for the data provided in hosts-2000.csv, rooms-2000.csv and bookings-2000.csv:

Search between 2012-06-01 and 2012-06-07 for 1 guest

host#1: Mr Host 1 1 Camden Street room#1 is available (1 booked, 1 free out of 2 total) room#2 is available (0 booked, 2 free out of 2 total)

host#2: Mr Host 2 2 Camden Street room#4 is available (0 booked, 2 free out of 2 total)

host#3: Mr Host 3 3 Camden Street room#5 is available (1 booked, 1 free out of 2 total) room#6 is available (0 booked, 2 free out of 2 total)

host#4: Mr Host 4 4 Camden Street room#8 is available (0 booked, 2 free out of 2 total)

host#5: Mr Host 5 5 Camden Street room#9 is available (1 booked, 1 free out of 2 total) room#10 is available (0 booked, 2 free out of 2 total)

Paginate results, show 5 hosts per page.

A description of how the problem was solved will be included with any possible considerations and instructions to run the application and load the data.

== Comments

===Gemfile:

  • haml support added
  • puma support added
  • debugger support added
  • annotate support added
  • simple_form support added
  • better_errors added

GitIgnore update.

Sass as default template. (config/application.rb -> config.sass.preferred_syntax = :sass)

===Model branch

rails g annotate_models:install rails g model host name:string address:text rails g model room host_id:integer capacity:integer rails g model booking room_id:integer start_date:date end_date:date number_of_guests:integer

Indexes: host.name, room.host_id, booking.room_id, booking.start_date, booking.end_date

Associations: host.id -> room.host_id (1:N) room.id -> booking.room_id (1:N)

Default scope settings: order

===Rake_csv_import branch

  • Copy csv files in db folder, add it to .gitignore.

  • Rake task in /lib/tasks/import.rake

  • Run "rake import"

  • Run this import process only once in an environment. Examples: Import data in development environment:

    rake import RAILS_ENV=development

Import data in production environment:

rake import RAILS_ENV=production

===Search form

Search with model:

rails g model search s_date:date e_date:date n_guests:integer rails g controller searches

Logics implemented in models.

Results use models' partials.

===Test application is running on Heroku

http://desolate-journey-7350.herokuapp.com/

==TODO

  • Creating a full featured booking system which could use everybody for free!!
  • Updating room model
  • Updating host model
  • Paginate results
  • Admin for host and home
  • Bulding user registration/login feature
  • Upgrading search function
  • Implementing booking feature
  • Updating all app to Rails 4
  • Refactoring queries
  • Make more object oriented...

homework's People

Contributors

zoltan-nz avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.