Skip to content

ganesharulanantham/filter-app-rails-backend

Repository files navigation

README

Filter-app - serves as a backend rails api for the filter-app-frontend. It is a simple prototype to work with tabular data of a city.

Clone The project:


Recursive clone to clone all the submodules

git clone --recursive [email protected]:ganesh-hobbeez/filter-app.git

How to setup


Rails app for API:

Go to Rails app folder path ex: cd filter-app/
  1. bundle install

  2. Create Database and sample seed

    rake app:bootstrap
    
  3. Run the server

    rails s
    
  4. Connect to “localhost:3000/screenings.json

Ember app as server:

Go to Rails app folder path ex: cd filter-app/filter-app-frontend/
  1. npm install

  2. bower install

  3. ember serve

  4. Connect to “localhost:4200/screenings

For info:

Inside ember app host_url is specified in adatper/application.js pointing to rails api server
host: 'http://localhost:3000'

Frontend App api documentation

Sample data here have information of a Movies screened in San Francisco city with following info:

  • Title

  • Locations

  • Release Year

  • Production Company

  • Director

  • Distributor

  • Writer

  • Actor 1

  • Actor 2

  • Actor 3

  • Fun Facts

  • Latitude

  • Longitude

Rails api with

Common Accepted params for all actions:

offset - To offset record by specific length
limit - To limit number of records returned by specific length
sort_by - Can specify the any of the data attribute as string
direction - desc or asc
  1. Ex: GET - localhost:3000/screenings.json?offset=0&limit=1&sort_by=title&direction=desc

{

"screenings": [
    {
        "id": 1,
        "title": "180",
        "locations": "Epic Roasthouse (399 Embarcadero)",
        "release_year": 2011,
        "production_company": "SPI Cinemas",
        "actor_1": "Siddarth",
        "actor_2": "Nithya Menon",
        "actor_3": "Priya Anand",
        "director": "Jayendra",
        "distributor": null,
        "writer": "Umarji Anuradha, Jayendra, Aarthi Sriram, & Suba ",
        "created_at": "2016-02-28T17:51:30.000Z",
        "updated_at": "2016-02-28T17:51:30.000Z",
        "fun_facts": null,
        "latitude": "36.89268497081403",
        "longitude": "-119.84640472076148"
    }
]

}

For getting filtered data:

  1. POST - localhost:3000/screenings/filters.json?offset=0&limit=1&sort_by=title&direction=desc

Supports multiple data attribute:
  {"attributes": { "title": { "operator": "is_equal_to", 
                              "value": "180", 
                              "condition": "and" },
                   "locations": { "operator": "is_equal_to", 
                                  "value": "City Hall", 
                                  "condition": "and" }
               }}

Filtered data: {

"screenings": [
  {
    "id": 5,
    "title": "180",
    "locations": "City Hall",
    "release_year": 2011,
    "production_company": "SPI Cinemas",
    "actor_1": "Siddarth",
    "actor_2": "Nithya Menon",
    "actor_3": "Priya Anand",
    "director": "Jayendra",
    "distributor": null,
    "writer": "Umarji Anuradha, Jayendra, Aarthi Sriram, & Suba ",
    "created_at": "2016-02-28T17:51:30.000Z",
    "updated_at": "2016-02-28T17:51:30.000Z",
    "fun_facts": null,
    "latitude": "36.45570303378161",
    "longitude": "-119.9128015700618"
  }
]

}

Params structure to get filtered data for each data attibutes: 
  { data_attribute: { operatior: "",
                      value: "",
                      condition: ""}
                      }

  operators: ex("is_equal_to" or "is_not_equal_to")
  value: Any string or integer
  condition: ex('or' or 'and')
  1. Filter options quick search: localhost:3000/screenings/options?offset=0&limit=10&sort_by=title&direction=desc&key=title&value=bie Params:

    ex: key: 'title'  (any of the data attribute)
        value: 'abc'  (query parameter)
Unique option data:
  [
    {
      "id": 438,
      "text": "Herbie Rides Again"
    },
    {
      "id": 362,
      "text": "Freebie and the Bean"
    },
    {
      "id": 90,
      "text": "Babies"
    }
  ]

About

Simple filter app using rails backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published