├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── application_record.rb │ ├── violation.rb │ ├── inspection.rb │ └── restaurant.rb ├── assets │ ├── images │ │ ├── .keep │ │ └── nyc-restaurant-grades.jpg │ ├── stylesheets │ │ ├── home.scss │ │ └── application.css │ └── javascripts │ │ └── application.js ├── controllers │ ├── concerns │ │ └── .keep │ ├── home_controller.rb │ ├── application_controller.rb │ ├── api │ │ └── v1 │ │ │ ├── restaurants_controller.rb │ │ │ ├── violations_controller.rb │ │ │ └── inspections_controller.rb │ └── graphql_controller.rb ├── helpers │ └── application_helper.rb ├── workers │ └── update_dataset_worker.rb ├── views │ ├── home │ │ └── index.html.erb │ └── layouts │ │ └── application.html.erb └── graph │ └── graph │ ├── connections │ ├── violations.rb │ ├── inspections.rb │ └── restaurants.rb │ ├── enum │ └── restaurant_borough_enum.rb │ ├── loaders │ ├── record_loader.rb │ ├── relay_foreign_key_loader.rb │ └── foreign_key_loader.rb │ ├── types │ ├── violation.rb │ ├── restaurant.rb │ ├── inspection.rb │ └── root_query.rb │ └── schema.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── inspection_test.rb │ ├── restaurant_test.rb │ └── violation_test.rb ├── controllers │ ├── .keep │ └── home_controller_test.rb ├── fixtures │ ├── .keep │ ├── violations.yml │ ├── restaurants.yml │ └── inspections.yml ├── integration │ └── .keep ├── workers │ └── update_dataset_worker_test.rb └── test_helper.rb ├── .ruby-version ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── Procfile ├── .dockerignore ├── config ├── initializers │ ├── graphiql.rb │ ├── session_store.rb │ ├── mime_types.rb │ ├── sidekiq.rb │ ├── filter_parameter_logging.rb │ ├── application_controller_renderer.rb │ ├── cookies_serializer.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── assets.rb │ ├── inflections.rb │ ├── new_framework_defaults.rb │ ├── content_security_policy.rb │ └── new_framework_defaults_5_2.rb ├── spring.rb ├── environment.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── routes.rb ├── application.rb ├── locales │ └── en.yml ├── secrets.yml ├── storage.yml ├── puma.rb ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb ├── database.yml └── schema.graphql ├── bin ├── rake ├── bundle ├── rails ├── yarn ├── spring ├── update └── setup ├── .env.example ├── config.ru ├── db ├── migrate │ ├── 20160608204459_add_phone_number_to_restaurant.rb │ ├── 20170311163627_remove_violation_data_from_inspection.rb │ ├── 20170311163041_create_violations.rb │ ├── 20170312170343_add_uniqueness_indexes.rb │ ├── 20160605211006_create_restaurants.rb │ └── 20160605210829_create_inspections.rb ├── schema.rb └── seeds.rb ├── script └── dump-graphql-schema ├── Rakefile ├── Dockerfile ├── .gitignore ├── README.md ├── Gemfile └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.5.1 2 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec puma -C config/puma.rb 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .dockerignore 3 | log/* 4 | tmp/* 5 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /config/initializers/graphiql.rb: -------------------------------------------------------------------------------- 1 | GraphiQL::Rails.config.csrf = true 2 | -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | SECRET_KEY_BASE= 2 | DATABASE_URL=postgres://postgres@db:5432/nyc-restaurant-grades_production 3 | REDIS_URL=redis://redis:6379/0 4 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w( 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ).each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /app/assets/images/nyc-restaurant-grades.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bswinnerton/nyc-restaurant-grades/HEAD/app/assets/images/nyc-restaurant-grades.jpg -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../config/application', __dir__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /app/workers/update_dataset_worker.rb: -------------------------------------------------------------------------------- 1 | class UpdateDatasetWorker 2 | include Sidekiq::Worker 3 | 4 | def perform(*args) 5 | Rails.application.load_seed 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/inspection_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class InspectionTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/restaurant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class RestaurantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/violation_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ViolationTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= image_tag('nyc-restaurant-grades.jpg') %> 3 |
4 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_nyc_restaurant_grades_session' 4 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /db/migrate/20160608204459_add_phone_number_to_restaurant.rb: -------------------------------------------------------------------------------- 1 | class AddPhoneNumberToRestaurant < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :restaurants, :phone_number, :text 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /config/initializers/sidekiq.rb: -------------------------------------------------------------------------------- 1 | Sidekiq.configure_server do |config| 2 | config.redis = { url: ENV['RESQUE_URL'] } 3 | end 4 | 5 | Sidekiq.configure_client do |config| 6 | config.redis = { url: ENV['RESQUE_URL'] } 7 | end 8 | -------------------------------------------------------------------------------- /test/workers/update_dataset_worker_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | class UpdateDatasetWorkerTest < MiniTest::Unit::TestCase 3 | def test_example 4 | skip "add some examples to (or delete) #{__FILE__}" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/controllers/home_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class HomeControllerTest < ActionController::TestCase 4 | test "should get index" do 5 | get :index 6 | assert_response :success 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /script/dump-graphql-schema: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.expand_path('../../config/environment', __FILE__) 3 | 4 | schema = GraphQL::Schema::Printer.print_schema(Graph::Schema) 5 | File.write('config/schema.graphql', "#{schema.chomp}\n") 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: nyc_restaurant_grades_production 11 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /test/fixtures/violations.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | description: MyText 5 | code: MyText 6 | inspection_id: 1 7 | 8 | two: 9 | description: MyText 10 | code: MyText 11 | inspection_id: 1 12 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /db/migrate/20170311163627_remove_violation_data_from_inspection.rb: -------------------------------------------------------------------------------- 1 | class RemoveViolationDataFromInspection < ActiveRecord::Migration[4.2] 2 | def change 3 | remove_column :inspections, :violation_code, :text 4 | remove_column :inspections, :violation_description, :text 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/home.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the home controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | 5 | .home-image img { 6 | height: 500px; 7 | display: block; 8 | margin: 5% auto; 9 | } 10 | -------------------------------------------------------------------------------- /db/migrate/20170311163041_create_violations.rb: -------------------------------------------------------------------------------- 1 | class CreateViolations < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :violations do |t| 4 | t.text :description 5 | t.text :code 6 | t.integer :inspection_id 7 | 8 | t.timestamps null: false 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20170312170343_add_uniqueness_indexes.rb: -------------------------------------------------------------------------------- 1 | class AddUniquenessIndexes < ActiveRecord::Migration[4.2] 2 | def change 3 | add_index :restaurants, :camis, unique: true 4 | add_index :inspections, [:restaurant_id, :inspected_at], unique: true 5 | add_index :violations, [:inspection_id, :code], unique: true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/graph/graph/connections/violations.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Connections 3 | Violations = Types::Violation.define_connection do 4 | name "ViolationsConnection" 5 | 6 | field :totalCount do 7 | type types.Int 8 | resolve -> (obj, args, ctx) { obj.nodes.count } 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/controllers/api/v1/restaurants_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::V1::RestaurantsController < ApplicationController 2 | def index 3 | restaurants = Restaurant.limit(Restaurant::MAX_COUNT) 4 | render json: restaurants 5 | end 6 | 7 | def show 8 | restaurant = Restaurant.find(params[:id]) 9 | render json: restaurant 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/graph/graph/connections/inspections.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Connections 3 | Inspections = Types::Inspection.define_connection do 4 | name "InspectionsConnection" 5 | 6 | field :totalCount do 7 | type types.Int 8 | resolve -> (obj, args, ctx) { obj.nodes.count } 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/graph/graph/connections/restaurants.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Connections 3 | Restaurants = Types::Restaurant.define_connection do 4 | name "RestaurantsConnection" 5 | 6 | field :totalCount do 7 | type types.Int 8 | resolve -> (obj, args, ctx) { obj.nodes.count } 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | begin 5 | exec "yarnpkg", *ARGV 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/graph/graph/enum/restaurant_borough_enum.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Types 3 | RestaurantBoroughEnum = GraphQL::EnumType.define do 4 | name "RestaurantBorough" 5 | description "The borough in which the Restaurant resides." 6 | 7 | ::Restaurant.boroughs.each { |name, _| value(name, name.titleize) } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /app/controllers/api/v1/violations_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::V1::ViolationsController < ApplicationController 2 | def index 3 | inspection = Inspection.find(params[:inspection_id]) 4 | violations = inspection.violations.limit(Violation::MAX_COUNT) 5 | render json: violations 6 | end 7 | 8 | def show 9 | violation = Violation.find(params[:id]) 10 | render json: violation 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20160605211006_create_restaurants.rb: -------------------------------------------------------------------------------- 1 | class CreateRestaurants < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :restaurants do |t| 4 | t.text :name 5 | t.text :camis 6 | t.text :building_number 7 | t.text :street 8 | t.text :zipcode 9 | t.integer :borough 10 | t.text :cuisine 11 | 12 | t.timestamps null: false 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/controllers/api/v1/inspections_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::V1::InspectionsController < ApplicationController 2 | def index 3 | restaurant = Restaurant.find(params[:restaurant_id]) 4 | inspections = restaurant.inspections.limit(Inspection::MAX_COUNT) 5 | render json: inspections 6 | end 7 | 8 | def show 9 | inspection = Inspection.find(params[:id]) 10 | render json: inspection 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /test/fixtures/restaurants.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | name: MyText 5 | camis: MyText 6 | building_number: MyText 7 | street: MyText 8 | zipcode: MyText 9 | borough: MyText 10 | cuisine: MyText 11 | 12 | two: 13 | name: MyText 14 | camis: MyText 15 | building_number: MyText 16 | street: MyText 17 | zipcode: MyText 18 | borough: MyText 19 | cuisine: MyText 20 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | z04Y7QnafOzl1KSwLBNwv/1EuTJDQsnsQd8K2aQXu3PjJmpnJtfs8STqdK9WmhxJItxwUIOli6rE30ot4jWvWDp/Ez6EI053nidPkX+P/V1kpoKMW8X102wtBo7UI3d1X+uDAx0ZC+u2zMsyHeNHizO1t2QajetAcjHg4VmFC22NTUtlAedlBQkHbn+CYt510T1zQ2wkN2q9soOWPqTzL/kt9hsZCqH4fNBzwhQXVXQd8GbaeillC023U8RYJG+ln2zVbYeTR8vM/ksCwqBT5c7JZQE49LnB/CxBBZ3C6rlilttaK0gGGP9Ee1DbcIjA6+QDzRLQLY50+FYXPcJyDwuj4fbTZnUWnDpkc7OBc+balfYFf8W5zdwZRwCf471qEXLRw0uTitDR+CahohON6GTxTsd6tvSxppk4--lTamfI8uUT5D58Uv--i5SyXb9dfQqzBHT1mc0mrg== -------------------------------------------------------------------------------- /app/controllers/graphql_controller.rb: -------------------------------------------------------------------------------- 1 | class GraphqlController < ApplicationController 2 | skip_before_action :verify_authenticity_token, only: [:create] 3 | 4 | def create 5 | result = Graph::Schema.execute(params[:query], variables: query_variables) 6 | render json: result 7 | end 8 | 9 | private 10 | 11 | def query_variables 12 | variables = params[:variables] 13 | 14 | if variables.present? 15 | JSON.parse(vars) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/graph/graph/loaders/record_loader.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Loaders 3 | class RecordLoader < GraphQL::Batch::Loader 4 | def initialize(model) 5 | @model = model 6 | end 7 | 8 | def perform(ids) 9 | model.where(id: ids).each { |record| fulfill(record.id, record) } 10 | ids.each { |id| fulfill(id, nil) unless fulfilled?(id) } 11 | end 12 | 13 | private 14 | 15 | attr_reader :model 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NYC Restaurant Grades API 5 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 6 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 7 | <%= csrf_meta_tags %> 8 | 9 | 10 | 11 | 12 | <%= yield %> 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /db/migrate/20160605210829_create_inspections.rb: -------------------------------------------------------------------------------- 1 | class CreateInspections < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :inspections do |t| 4 | t.integer :restaurant_id 5 | t.text :type 6 | t.datetime :inspected_at 7 | t.datetime :graded_at 8 | t.integer :score 9 | t.text :violation_description 10 | t.text :violation_code 11 | t.text :grade 12 | 13 | t.timestamps null: false 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root 'home#index' 3 | 4 | mount GraphiQL::Rails::Engine, at: '/graphql', graphql_path: '/graphql' 5 | 6 | namespace :api do 7 | namespace :v1 do 8 | resources :restaurants, only: [:index, :show] do 9 | resources :inspections, only: [:index, :show] do 10 | resources :violations, only: [:index, :show] 11 | end 12 | end 13 | end 14 | end 15 | 16 | post '/graphql' => 'graphql#create' 17 | end 18 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) 11 | Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } 12 | gem 'spring', match[1] 13 | require 'spring/binstub' 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.5.1 2 | 3 | # Install dependencies 4 | RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs 5 | 6 | # Set working directory, where the commands will be ran: 7 | RUN mkdir -p /var/www/app 8 | WORKDIR /var/www/app 9 | 10 | # Adding gems 11 | COPY Gemfile Gemfile 12 | COPY Gemfile.lock Gemfile.lock 13 | RUN bundle install --jobs 20 --retry 5 14 | 15 | # Adding project files 16 | COPY . . 17 | 18 | # Precompile assets 19 | RUN bundle exec rails assets:precompile 20 | 21 | CMD [ "bundle", "exec", "puma", "-C", "config/puma.rb" ] 22 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | !/log/.keep 13 | /tmp 14 | 15 | /vendor/bundle 16 | 17 | .env 18 | 19 | # Ignore master key for decrypting credentials and more. 20 | /config/master.key 21 | -------------------------------------------------------------------------------- /test/fixtures/inspections.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | restaurant_id: 1 5 | type: MyText 6 | inspected_at: 2016-06-05 17:08:29 7 | graded_at: 2016-06-05 17:08:29 8 | score: 1 9 | violation_description: MyText 10 | violation_code: MyText 11 | grade: MyText 12 | 13 | two: 14 | restaurant_id: 1 15 | type: MyText 16 | inspected_at: 2016-06-05 17:08:29 17 | graded_at: 2016-06-05 17:08:29 18 | score: 1 19 | violation_description: MyText 20 | violation_code: MyText 21 | grade: MyText 22 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require turbolinks 14 | //= require_tree . 15 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module NycRestaurantGrades 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.0 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration can go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded after loading 17 | # the framework and any gems in your application. 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /app/graph/graph/loaders/relay_foreign_key_loader.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Loaders 3 | class RelayForeignKeyLoader < GraphQL::Batch::Loader 4 | def initialize(model, foreign_key) 5 | @model = model 6 | @foreign_key = foreign_key 7 | end 8 | 9 | def perform(foreign_ids) 10 | records = model.where(foreign_key => foreign_ids.uniq).to_a 11 | 12 | foreign_ids.each do |foreign_id| 13 | matching_records = records.select do |record| 14 | record.send(foreign_key) == foreign_id 15 | end 16 | 17 | fulfill(foreign_id, matching_records) 18 | end 19 | end 20 | 21 | private 22 | 23 | attr_reader :model, :foreign_key 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/graph/graph/loaders/foreign_key_loader.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Loaders 3 | class ForeignKeyLoader < GraphQL::Batch::Loader 4 | def initialize(model, foreign_key) 5 | @model = model 6 | @foreign_key = foreign_key 7 | end 8 | 9 | def perform(foreign_ids) 10 | ids = foreign_ids.uniq 11 | scope = model.where(foreign_key => ids).limit(model::MAX_COUNT) 12 | records = scope.to_a 13 | 14 | foreign_ids.each do |foreign_id| 15 | matching_records = records.select do |record| 16 | record.send(foreign_key) == foreign_id 17 | end 18 | 19 | fulfill(foreign_id, matching_records) 20 | end 21 | end 22 | 23 | private 24 | 25 | attr_reader :model, :foreign_key 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /app/graph/graph/types/violation.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Types 3 | Violation = GraphQL::ObjectType.define do 4 | name 'Violation' 5 | description 'A NYC health inspection violation.' 6 | 7 | implements GraphQL::Relay::Node.interface 8 | global_id_field :id 9 | 10 | field :description do 11 | type types.String 12 | description 'The description of the violation.' 13 | end 14 | 15 | field :code do 16 | type types.String 17 | description 'The violation code cited.' 18 | end 19 | 20 | field :inspection do 21 | type -> { Types::Inspection } 22 | description 'The inspection this violation was a part of.' 23 | 24 | resolve -> (violation, arguments, context) do 25 | Loaders::RecordLoader.for(::Inspection).load(violation.inspection_id) 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /app/models/violation.rb: -------------------------------------------------------------------------------- 1 | class Violation < ApplicationRecord 2 | include Rails.application.routes.url_helpers 3 | 4 | MAX_COUNT = 30 5 | 6 | attr_accessor :restaurant_camis, :inspected_at 7 | 8 | belongs_to :inspection 9 | has_one :restaurant, through: :inspection 10 | 11 | validates :inspection_id, presence: true 12 | validates :code, uniqueness: { scope: :inspection_id } 13 | 14 | def url 15 | api_v1_restaurant_inspection_violation_url(restaurant, inspection, self) 16 | end 17 | 18 | def inspection_url 19 | api_v1_restaurant_inspection_url(restaurant, inspection) 20 | end 21 | 22 | def restaurant_url 23 | api_v1_restaurant_url(restaurant) 24 | end 25 | 26 | def as_json(options = {}) 27 | { 28 | id: id, 29 | description: description, 30 | code: code, 31 | url: url, 32 | inspection_url: inspection_url, 33 | restaurant_url: restaurant_url, 34 | } 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a way to update your development environment automatically. 14 | # Add necessary update steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | puts "\n== Updating database ==" 24 | system! 'bin/rails db:migrate' 25 | 26 | puts "\n== Removing old logs and tempfiles ==" 27 | system! 'bin/rails log:clear tmp:clear' 28 | 29 | puts "\n== Restarting application server ==" 30 | system! 'bin/rails restart' 31 | end 32 | -------------------------------------------------------------------------------- /app/graph/graph/schema.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | # Allow for connection.nodes shorthand 3 | GraphQL::Relay::ConnectionType.default_nodes_field = true 4 | 5 | Schema = GraphQL::Schema.define do 6 | query Graph::Types::RootQuery 7 | 8 | lazy_resolve(Promise, :sync) 9 | instrument(:query, GraphQL::Batch::Setup) 10 | 11 | default_max_page_size [Restaurant::MAX_COUNT, Violation::MAX_COUNT, Inspection::MAX_COUNT].min 12 | 13 | object_from_id -> (id, context) do 14 | type_name, database_id = GraphQL::Schema::UniqueWithinType.decode(id) 15 | type_name.constantize.find(database_id) 16 | end 17 | 18 | id_from_object -> (object, type_definition, context) do 19 | GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id) 20 | end 21 | 22 | resolve_type -> (object, context) do 23 | type_name = object.class.name.demodulize 24 | Graph::Schema.types[type_name] 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 5.0 upgrade. 4 | # 5 | # Once upgraded flip defaults one by one to migrate to the new default. 6 | # 7 | # Read the Rails 5.0 release notes for more info on each option. 8 | 9 | # Enable per-form CSRF tokens. Previous versions had false. 10 | Rails.application.config.action_controller.per_form_csrf_tokens = false 11 | 12 | # Enable origin-checking CSRF mitigation. Previous versions had false. 13 | Rails.application.config.action_controller.forgery_protection_origin_check = false 14 | 15 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. 16 | # Previous versions had false. 17 | ActiveSupport.to_time_preserves_timezone = false 18 | 19 | # Require `belongs_to` associations by default. Previous versions had false. 20 | Rails.application.config.active_record.belongs_to_required_by_default = false 21 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /app/models/inspection.rb: -------------------------------------------------------------------------------- 1 | class Inspection < ApplicationRecord 2 | include Rails.application.routes.url_helpers 3 | 4 | MAX_COUNT = 30 5 | 6 | attr_accessor :restaurant_camis 7 | 8 | self.inheritance_column = 'sti_type' 9 | 10 | belongs_to :restaurant 11 | has_many :violations 12 | 13 | validates :restaurant_id, presence: true 14 | validates :inspected_at, uniqueness: { scope: :restaurant_id } 15 | 16 | def url 17 | api_v1_restaurant_inspection_url(restaurant, self) 18 | end 19 | 20 | def restaurant_url 21 | api_v1_restaurant_url(restaurant) 22 | end 23 | 24 | def violations_url 25 | api_v1_restaurant_inspection_violations_url(restaurant, self) 26 | end 27 | 28 | def as_json(options = {}) 29 | { 30 | id: id, 31 | type: type, 32 | score: score, 33 | grade: grade, 34 | inspected_at: inspected_at, 35 | graded_at: graded_at, 36 | url: url, 37 | restaurant_url: restaurant_url, 38 | violations_url: violations_url, 39 | } 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 88088043144b915156b7fdfd518e904a7dc016b576a5694300bd12048fa563a44316598416727e9b509aca1cecc01cfeedd3f2c85d23b7db1a5bf8003f42064e 15 | 16 | test: 17 | secret_key_base: 0dc503001327df08600c74237a368df6d76f6c0d20a73e068b91fe49f816b73122427288e8c51a34b114b4a384a0e8d6e735c7d37411c8de9d56e0b030467634 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /app/models/restaurant.rb: -------------------------------------------------------------------------------- 1 | class Restaurant < ApplicationRecord 2 | include Rails.application.routes.url_helpers 3 | 4 | MAX_COUNT = 30 5 | 6 | enum borough: ['BRONX', 'BROOKLYN', 'MANHATTAN', 'STATEN_ISLAND', 'QUEENS'] 7 | 8 | has_many :inspections 9 | 10 | validates :camis, uniqueness: true 11 | 12 | def address 13 | "#{building_number} #{street}, #{borough.humanize}, New York #{zipcode}" 14 | end 15 | 16 | def grade 17 | return unless last_inspection 18 | last_inspection.grade 19 | end 20 | 21 | def url 22 | api_v1_restaurant_url(self) 23 | end 24 | 25 | def inspections_url 26 | api_v1_restaurant_inspections_url(self) 27 | end 28 | 29 | def as_json(options = {}) 30 | { 31 | id: id, 32 | name: name, 33 | grade: grade, 34 | camis: camis, 35 | address: address, 36 | cuisine: cuisine, 37 | url: url, 38 | inspections_url: inspections_url, 39 | } 40 | end 41 | 42 | private 43 | 44 | def last_inspection 45 | inspections.where.not(grade: nil).order(inspected_at: :desc).last 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a starting point to setup your application. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:setup' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NYC Restaurant Grades via GraphQL 2 | 3 | This application allows you to query the [NYC Restaurant Inspection 4 | Results](https://data.cityofnewyork.us/Health/DOHMH-New-York-City-Restaurant-Inspection-Results/xx67-kt59/about) 5 | data (letter ratings for restaurants) via a GraphQL interface. 6 | 7 | For example, to query all of the Wendy's in Brooklyn and get a list of their 8 | health violations, visit http://nyc-restaurant-grades.com/graphql and enter the 9 | following on the left hand side of GraphiQL: 10 | 11 | ```graphql 12 | query { 13 | restaurants(name: "Wendy's", borough: BROOKLYN) { 14 | name 15 | address 16 | cuisine 17 | inspections { 18 | grade 19 | violations { 20 | description 21 | } 22 | } 23 | } 24 | } 25 | ``` 26 | 27 | ## Development 28 | 29 | This application can be bootstrapped by doing the following: 30 | 31 | ``` 32 | bundle install 33 | bundle exec rake db:create db:migrate db:seed 34 | ``` 35 | 36 | The `db:seed` will start the bulk import from the NYC open data website and is 37 | idempotent. 38 | 39 | **The data backing this application is not regularly updated** 40 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | 19 | # If you are using UJS then enable automatic nonce generation 20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 21 | 22 | # Report CSP violations to a specified URI 23 | # For further information see the following documentation: 24 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 25 | # Rails.application.config.content_security_policy_report_only = true 26 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. 30 | # 31 | # preload_app! 32 | 33 | # Allow puma to be restarted by `rails restart` command. 34 | plugin :tmp_restart 35 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /app/graph/graph/types/restaurant.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Types 3 | Restaurant = GraphQL::ObjectType.define do 4 | name 'Restaurant' 5 | description 'A place of business serving food in New York City' 6 | 7 | implements GraphQL::Relay::Node.interface 8 | global_id_field :id 9 | 10 | field :name do 11 | type !types.String 12 | description 'The doing-business-as value.' 13 | end 14 | 15 | field :camis do 16 | type !types.String 17 | description 'The unique identifier.' 18 | end 19 | 20 | field :address do 21 | type types.String 22 | description 'The address of the restaurant.' 23 | end 24 | 25 | field :phoneNumber do 26 | type types.String 27 | description 'The phone number.' 28 | property :phone_number 29 | end 30 | 31 | field :cuisine do 32 | type types.String 33 | description 'The cuisine.' 34 | end 35 | 36 | field :grade do 37 | type types.String 38 | description 'The latest grade of an inspection.' 39 | end 40 | 41 | field :borough do 42 | type -> { RestaurantBoroughEnum } 43 | end 44 | 45 | field :inspections do 46 | type -> { types[Types::Inspection] } 47 | description 'List the inspections.' 48 | 49 | resolve -> (restaurant, arguments, context) do 50 | #TODO: Use order(inspected_at: :desc) 51 | Loaders::ForeignKeyLoader.for(::Inspection, :restaurant_id).load(restaurant.id) 52 | end 53 | end 54 | 55 | connection :paginatedInspections do 56 | type -> { Connections::Inspections } 57 | description 'The inspections of the restaurant as a Relay connection.' 58 | 59 | resolve -> (restaurant, arguments, context) do 60 | #TODO: Use order(inspected_at: :desc) 61 | Loaders::RelayForeignKeyLoader.for(::Inspection, :restaurant_id).load(restaurant.id) 62 | end 63 | end 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults_5_2.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 5.2 upgrade. 4 | # 5 | # Once upgraded flip defaults one by one to migrate to the new default. 6 | # 7 | # Read the Guide for Upgrading Ruby on Rails for more info on each option. 8 | 9 | # Make Active Record use stable #cache_key alongside new #cache_version method. 10 | # This is needed for recyclable cache keys. 11 | # Rails.application.config.active_record.cache_versioning = true 12 | 13 | # Use AES-256-GCM authenticated encryption for encrypted cookies. 14 | # Also, embed cookie expiry in signed or encrypted cookies for increased security. 15 | # 16 | # This option is not backwards compatible with earlier Rails versions. 17 | # It's best enabled when your entire app is migrated and stable on 5.2. 18 | # 19 | # Existing cookies will be converted on read then written with the new scheme. 20 | # Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true 21 | 22 | # Use AES-256-GCM authenticated encryption as default cipher for encrypting messages 23 | # instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. 24 | # Rails.application.config.active_support.use_authenticated_message_encryption = true 25 | 26 | # Add default protection from forgery to ActionController::Base instead of in 27 | # ApplicationController. 28 | # Rails.application.config.action_controller.default_protect_from_forgery = true 29 | 30 | # Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and 31 | # 'f' after migrating old data. 32 | # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true 33 | 34 | # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. 35 | # Rails.application.config.active_support.use_sha1_digests = true 36 | 37 | # Make `form_with` generate id attributes for any generated HTML tags. 38 | # Rails.application.config.action_view.form_with_generates_ids = true 39 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory 32 | config.active_storage.service = :test 33 | 34 | config.action_mailer.perform_caching = false 35 | 36 | # Tell Action Mailer not to deliver emails to the real world. 37 | # The :test delivery method accumulates sent emails in the 38 | # ActionMailer::Base.deliveries array. 39 | config.action_mailer.delivery_method = :test 40 | 41 | # Print deprecation notices to the stderr. 42 | config.active_support.deprecation = :stderr 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /app/graph/graph/types/inspection.rb: -------------------------------------------------------------------------------- 1 | module Graph 2 | module Types 3 | Inspection = GraphQL::ObjectType.define do 4 | name 'Inspection' 5 | description 'A NYC health inspection.' 6 | 7 | implements GraphQL::Relay::Node.interface 8 | global_id_field :id 9 | 10 | field :type do 11 | type types.String 12 | description 'The type of inspection.' 13 | end 14 | 15 | field :grade do 16 | type types.String 17 | description 'The grade received.' 18 | end 19 | 20 | field :score do 21 | type types.Int 22 | description 'The numeric score received.' 23 | end 24 | 25 | field :inspectedAt do 26 | type !types.String 27 | description 'The timestamp of the inspection.' 28 | property :inspected_at 29 | end 30 | 31 | field :gradedAt do 32 | type types.String 33 | description 'The timestamp of when the grade was received.' 34 | property :graded_at 35 | end 36 | 37 | field :restaurant do 38 | type -> { !Types::Restaurant } 39 | description 'The restaurant associated with the inspection.' 40 | 41 | resolve -> (object, arguments, context) do 42 | Loaders::RecordLoader.for(::Restaurant).load(object.restaurant_id) 43 | end 44 | end 45 | 46 | field :violations do 47 | type -> { types[Types::Violation] } 48 | description 'The violations received in the inspection.' 49 | 50 | resolve -> (inspection, arguments, context) do 51 | Loaders::ForeignKeyLoader.for(::Violation, :inspection_id).load(inspection.id) 52 | end 53 | end 54 | 55 | connection :paginatedViolations do 56 | type -> { !Connections::Violations } 57 | description 'The violations received in the inspection as a Relay connection.' 58 | 59 | resolve -> (inspection, arguments, context) do 60 | Loaders::RelayForeignKeyLoader.for(::Violation, :inspection_id).load(inspection.id) 61 | end 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2017_03_12_170343) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | create_table "inspections", id: :serial, force: :cascade do |t| 19 | t.integer "restaurant_id" 20 | t.text "type" 21 | t.datetime "inspected_at" 22 | t.datetime "graded_at" 23 | t.integer "score" 24 | t.text "grade" 25 | t.datetime "created_at", null: false 26 | t.datetime "updated_at", null: false 27 | t.index ["restaurant_id", "inspected_at"], name: "index_inspections_on_restaurant_id_and_inspected_at", unique: true 28 | end 29 | 30 | create_table "restaurants", id: :serial, force: :cascade do |t| 31 | t.text "name" 32 | t.text "camis" 33 | t.text "building_number" 34 | t.text "street" 35 | t.text "zipcode" 36 | t.integer "borough" 37 | t.text "cuisine" 38 | t.datetime "created_at", null: false 39 | t.datetime "updated_at", null: false 40 | t.text "phone_number" 41 | t.index ["camis"], name: "index_restaurants_on_camis", unique: true 42 | end 43 | 44 | create_table "violations", id: :serial, force: :cascade do |t| 45 | t.text "description" 46 | t.text "code" 47 | t.integer "inspection_id" 48 | t.datetime "created_at", null: false 49 | t.datetime "updated_at", null: false 50 | t.index ["inspection_id", "code"], name: "index_violations_on_inspection_id_and_code", unique: true 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | # Run rails dev:cache to toggle caching. 17 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | 20 | config.cache_store = :memory_store 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 | } 24 | else 25 | config.action_controller.perform_caching = false 26 | 27 | config.cache_store = :null_store 28 | end 29 | 30 | # Store uploaded files on the local file system (see config/storage.yml for options) 31 | config.active_storage.service = :local 32 | 33 | # Don't care if the mailer can't send. 34 | config.action_mailer.raise_delivery_errors = false 35 | 36 | config.action_mailer.perform_caching = false 37 | 38 | # Print deprecation notices to the Rails logger. 39 | config.active_support.deprecation = :log 40 | 41 | # Raise an error on page load if there are pending migrations. 42 | config.active_record.migration_error = :page_load 43 | 44 | # Highlight code that triggered database queries in logs. 45 | config.active_record.verbose_query_logs = true 46 | 47 | # Debug mode disables concatenation and preprocessing of assets. 48 | # This option may cause significant delays in view rendering with a large 49 | # number of complex assets. 50 | config.assets.debug = true 51 | 52 | # Suppress logger output for asset requests. 53 | config.assets.quiet = true 54 | 55 | # Raises error for missing translations 56 | # config.action_view.raise_on_missing_translations = true 57 | 58 | # Use an evented file watcher to asynchronously detect changes in source code, 59 | # routes, locales, etc. This feature depends on the listen gem. 60 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 61 | end 62 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.5.1' 5 | 6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7 | gem 'rails', '~> 5.2.1' 8 | # Use postgresql as the database for Active Record 9 | gem 'pg', '~> 0.21' 10 | # Use Puma as the app server 11 | gem 'puma', '~> 3.11' 12 | # Use SCSS for stylesheets 13 | gem 'sass-rails', '~> 5.0' 14 | # Use Uglifier as compressor for JavaScript assets 15 | gem 'uglifier', '>= 1.3.0' 16 | # See https://github.com/rails/execjs#readme for more supported runtimes 17 | # gem 'mini_racer', platforms: :ruby 18 | 19 | # Use CoffeeScript for .coffee assets and views 20 | gem 'coffee-rails', '~> 4.2' 21 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 22 | gem 'turbolinks', '~> 5' 23 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24 | gem 'jbuilder', '~> 2.5' 25 | # Use Redis adapter to run Action Cable in production 26 | # gem 'redis', '~> 4.0' 27 | # Use ActiveModel has_secure_password 28 | # gem 'bcrypt', '~> 3.1.7' 29 | 30 | # Use ActiveStorage variant 31 | # gem 'mini_magick', '~> 4.8' 32 | 33 | # Use Capistrano for deployment 34 | # gem 'capistrano-rails', group: :development 35 | 36 | # Reduces boot times through caching; required in config/boot.rb 37 | gem 'bootsnap', '>= 1.1.0', require: false 38 | 39 | group :development, :test do 40 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 42 | end 43 | 44 | group :development do 45 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 46 | gem 'web-console', '>= 3.3.0' 47 | gem 'listen', '>= 3.0.5', '< 3.2' 48 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 | gem 'spring' 50 | gem 'spring-watcher-listen', '~> 2.0.0' 51 | end 52 | 53 | group :test do 54 | # Adds support for Capybara system testing and selenium driver 55 | gem 'capybara', '>= 2.15' 56 | gem 'selenium-webdriver' 57 | # Easy installation and use of chromedriver to run system tests with Chrome 58 | gem 'chromedriver-helper' 59 | end 60 | 61 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 62 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 63 | 64 | gem 'rest-client' 65 | gem 'pry-rails' 66 | gem 'rails_12factor' 67 | gem 'graphiql-rails' 68 | gem 'graphql' 69 | gem 'graphql-batch' 70 | gem 'activerecord-import' 71 | gem 'sidekiq' 72 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 8.2 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On OS X with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On OS X with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see rails configuration guide 21 | # http://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: 5 23 | 24 | development: 25 | <<: *default 26 | database: nyc-restaurant-grades_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: nyc-restaurant-grades 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: nyc-restaurant-grades_test 61 | 62 | # As with config/secrets.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | url: <%= ENV['DATABASE_URL'] %> 84 | -------------------------------------------------------------------------------- /app/graph/graph/types/root_query.rb: -------------------------------------------------------------------------------- 1 | require 'graph/enum/restaurant_borough_enum' 2 | 3 | module Graph 4 | module Types 5 | RootQuery = GraphQL::ObjectType.define do 6 | name 'RootQuery' 7 | description 'The query root.' 8 | 9 | field :node, GraphQL::Relay::Node.field 10 | 11 | field :restaurant do 12 | type -> { Types::Restaurant } 13 | description 'Perform a search for one restaurant.' 14 | 15 | argument :name, types.String 16 | argument :borough, Types::RestaurantBoroughEnum 17 | 18 | resolve -> (object, arguments, context) do 19 | name = arguments['name'] 20 | 21 | if arguments['borough'] 22 | borough = ::Restaurant.boroughs[arguments['borough']] 23 | ::Restaurant.find_by(name: name, borough: borough) 24 | else 25 | ::Restaurant.find_by(name: name) 26 | end 27 | end 28 | end 29 | 30 | field :restaurants do 31 | type -> { !types[Types::Restaurant] } 32 | description 'Perform a search across all Restaurants.' 33 | 34 | argument :name, types.String 35 | argument :borough, Types::RestaurantBoroughEnum 36 | 37 | resolve -> (object, arguments, context) do 38 | name = arguments['name'] 39 | borough = ::Restaurant.boroughs[arguments['borough']] 40 | 41 | scope = if name && borough 42 | ::Restaurant.where(name: name, borough: borough) 43 | elsif name 44 | ::Restaurant.where(name: name) 45 | elsif borough 46 | ::Restaurant.where(borough: borough) 47 | else 48 | ::Restaurant.all 49 | end 50 | 51 | scope.limit(::Restaurant::MAX_COUNT) 52 | end 53 | end 54 | 55 | connection :paginatedRestaurants do 56 | type -> { !Connections::Restaurants } 57 | description 'Perform a search across all Restaurants and return a Relay connection.' 58 | 59 | argument :name, types.String 60 | argument :borough, Types::RestaurantBoroughEnum 61 | 62 | resolve -> (object, arguments, context) do 63 | name = arguments['name'] 64 | borough = ::Restaurant.boroughs[arguments['borough']] 65 | 66 | if name && borough 67 | ::Restaurant.where(name: name, borough: borough) 68 | elsif name 69 | ::Restaurant.where(name: name) 70 | elsif borough 71 | ::Restaurant.where(borough: borough) 72 | else 73 | ::Restaurant.all 74 | end 75 | end 76 | end 77 | 78 | field :inspections do 79 | type -> { !types[Types::Inspection] } 80 | description 'Perform a search across all Inspections.' 81 | 82 | argument :grade, types.String 83 | 84 | resolve -> (object, arguments, context) do 85 | grade = arguments['grade'] 86 | 87 | scope = if grade 88 | ::Inspection.includes(:restaurant).where(grade: grade) 89 | else 90 | ::Inspection.includes(:restaurant).all 91 | end 92 | 93 | scope.limit(::Inspection::MAX_COUNT) 94 | end 95 | end 96 | 97 | connection :paginatedInspections do 98 | type -> { !Connections::Inspections } 99 | description 'Perform a search across all Inspections.' 100 | 101 | argument :grade, types.String 102 | 103 | resolve -> (object, arguments, context) do 104 | grade = arguments['grade'] 105 | 106 | if grade 107 | ::Inspection.includes(:restaurant).where(grade: grade) 108 | else 109 | ::Inspection.includes(:restaurant).all 110 | end 111 | end 112 | end 113 | end 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | # config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = Uglifier.new(harmony: true) 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 33 | 34 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 35 | # config.action_controller.asset_host = 'http://assets.example.com' 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 40 | 41 | # Store uploaded files on the local file system (see config/storage.yml for options) 42 | config.active_storage.service = :local 43 | 44 | # Mount Action Cable outside main process or domain 45 | # config.action_cable.mount_path = nil 46 | # config.action_cable.url = 'wss://example.com/cable' 47 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 48 | 49 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 50 | # config.force_ssl = true 51 | 52 | # Use the lowest log level to ensure availability of diagnostic information 53 | # when problems arise. 54 | config.log_level = :debug 55 | 56 | # Prepend all log lines with the following tags. 57 | config.log_tags = [ :request_id ] 58 | 59 | # Use a different cache store in production. 60 | # config.cache_store = :mem_cache_store 61 | 62 | # Use a real queuing backend for Active Job (and separate queues per environment) 63 | # config.active_job.queue_adapter = :resque 64 | # config.active_job.queue_name_prefix = "nyc_restaurant_grades_#{Rails.env}" 65 | 66 | config.action_mailer.perform_caching = false 67 | 68 | # Ignore bad email addresses and do not raise email delivery errors. 69 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 70 | # config.action_mailer.raise_delivery_errors = false 71 | 72 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 73 | # the I18n.default_locale when a translation cannot be found). 74 | config.i18n.fallbacks = true 75 | 76 | # Send deprecation notices to registered listeners. 77 | config.active_support.deprecation = :notify 78 | 79 | # Use default logging formatter so that PID and timestamp are not suppressed. 80 | config.log_formatter = ::Logger::Formatter.new 81 | 82 | # Use a different logger for distributed setups. 83 | # require 'syslog/logger' 84 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 85 | 86 | if ENV["RAILS_LOG_TO_STDOUT"].present? 87 | logger = ActiveSupport::Logger.new(STDOUT) 88 | logger.formatter = config.log_formatter 89 | config.logger = ActiveSupport::TaggedLogging.new(logger) 90 | end 91 | 92 | # Do not dump schema after migrations. 93 | config.active_record.dump_schema_after_migration = false 94 | end 95 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # Suppress SQL output 2 | old_active_record_log_level = ActiveRecord::Base.logger.level 3 | ActiveRecord::Base.logger.level = 1 4 | 5 | class DataSet 6 | ORDER = :id.freeze 7 | LIMIT = 50000.freeze 8 | 9 | attr_accessor :page 10 | 11 | def initialize 12 | @page = 0 13 | end 14 | 15 | def endpoint 16 | "https://data.cityofnewyork.us/resource/9w7m-hzhe.json?#{parameters}" 17 | end 18 | 19 | def parameters 20 | return unless ORDER && LIMIT && offset 21 | "$order=:#{ORDER}&$limit=#{LIMIT}&$offset=#{offset}" 22 | end 23 | 24 | private 25 | 26 | def offset 27 | page * LIMIT 28 | end 29 | end 30 | 31 | broken = false 32 | dataset = DataSet.new 33 | 34 | restaurants = [] 35 | inspections = [] 36 | violations = [] 37 | 38 | Rails.logger.info "Starting import of NYC OpenData dataset..." 39 | 40 | while !broken 41 | begin 42 | Rails.logger.info "Fetching page #{dataset.page}..." 43 | 44 | response = RestClient.get(dataset.endpoint) 45 | parsed_response = JSON.parse(response) 46 | 47 | if parsed_response.empty? 48 | Rails.logger.info "Fetched all pages." 49 | break 50 | end 51 | 52 | parsed_response.each do |restaurant_data| 53 | next unless restaurant_data['dba'] 54 | 55 | restaurant = Restaurant.new( 56 | camis: restaurant_data['camis'], 57 | name: restaurant_data['dba'].titleize, 58 | building_number: restaurant_data['building'], 59 | street: restaurant_data['street'].titleize, 60 | zipcode: restaurant_data['zipcode'], 61 | borough: Restaurant.boroughs[restaurant_data['boro'].parameterize.underscore.upcase], 62 | phone_number: restaurant_data['phone'], 63 | cuisine: restaurant_data['cuisine_description'], 64 | ) 65 | 66 | restaurants << restaurant 67 | end 68 | 69 | parsed_response.each do |restaurant_data| 70 | next unless restaurant_data['dba'] 71 | 72 | inspection = Inspection.new( 73 | inspected_at: restaurant_data['inspection_date'].to_datetime, 74 | type: restaurant_data['inspection_type'], 75 | graded_at: restaurant_data['grade_date'], 76 | score: restaurant_data['score'], 77 | grade: restaurant_data['grade'], 78 | ) 79 | 80 | inspection.restaurant_camis = restaurant_data['camis'] 81 | 82 | inspections << inspection 83 | end 84 | 85 | parsed_response.each do |restaurant_data| 86 | next unless restaurant_data['dba'] 87 | 88 | violation_description = restaurant_data['violation_description'] 89 | violation_code = restaurant_data['violation_code'] 90 | 91 | if violation_description || violation_code 92 | violation = Violation.new( 93 | code: violation_code, 94 | description: violation_description, 95 | ) 96 | 97 | violation.restaurant_camis = restaurant_data['camis'] 98 | violation.inspected_at = restaurant_data['inspection_date'].to_datetime 99 | 100 | violations << violation 101 | end 102 | end 103 | 104 | dataset.page += 1 105 | 106 | restaurants = restaurants.uniq 107 | inspections = inspections.uniq 108 | violations = violations.uniq 109 | rescue Exception => exception 110 | Rails.logger.info "Fetching failed at page #{dataset.page}." 111 | Rails.logger.fatal exception 112 | broken = true 113 | end 114 | end 115 | 116 | Rails.logger.info "Importing Restaurants..." 117 | Restaurant.import(restaurants, batch_size: 50000, on_duplicate_key_ignore: { conflict_target: [:camis], columns: [:updated_at] }) 118 | 119 | Rails.logger.info "Caching Restaurants..." 120 | persisted_restaurants = Restaurant.all.group_by(&:camis) 121 | 122 | Rails.logger.info "Building Inspections..." 123 | inspections = inspections.map do |inspection| 124 | restaurant = persisted_restaurants[inspection.restaurant_camis].first 125 | inspection.restaurant_id = restaurant.id 126 | inspection 127 | end 128 | 129 | Rails.logger.info "Importing Inspections..." 130 | Inspection.import(inspections, batch_size: 50000, on_duplicate_key_ignore: true) 131 | 132 | Rails.logger.info "Caching Inspections..." 133 | persisted_inspections = Inspection.all.group_by(&:restaurant_id) 134 | 135 | Rails.logger.info "Building Violations..." 136 | violations = violations.map do |violation| 137 | restaurant = persisted_restaurants[violation.restaurant_camis].first 138 | restaurant_inspections = persisted_inspections[restaurant.id] 139 | 140 | inspection = restaurant_inspections.find do |inspection| 141 | inspection.inspected_at == violation.inspected_at 142 | end 143 | 144 | violation.inspection = inspection 145 | violation 146 | end 147 | 148 | Rails.logger.info "Importing Violations..." 149 | Violation.import(violations, batch_size: 50000, on_duplicate_key_ignore: true) 150 | 151 | Rails.logger.info "Import of NYC OpenData dataset complete." 152 | 153 | # Reset logger to what it was before this script began 154 | ActiveRecord::Base.logger.level = old_active_record_log_level 155 | -------------------------------------------------------------------------------- /config/schema.graphql: -------------------------------------------------------------------------------- 1 | schema { 2 | query: RootQuery 3 | } 4 | 5 | # A NYC health inspection. 6 | type Inspection implements Node { 7 | id: ID! 8 | 9 | # The type of inspection. 10 | type: String 11 | 12 | # The grade received. 13 | grade: String 14 | 15 | # The numeric score received. 16 | score: Int 17 | 18 | # The timestamp of the inspection. 19 | inspectedAt: String! 20 | 21 | # The timestamp of when the grade was received. 22 | gradedAt: String 23 | 24 | # The restaurant associated with the inspection. 25 | restaurant: Restaurant! 26 | 27 | # The violations received in the inspection. 28 | violations: [Violation] 29 | 30 | # The violations received in the inspection as a Relay connection. 31 | paginatedViolations( 32 | # Returns the first _n_ elements from the list. 33 | first: Int 34 | 35 | # Returns the elements in the list that come after the specified global ID. 36 | after: String 37 | 38 | # Returns the last _n_ elements from the list. 39 | last: Int 40 | 41 | # Returns the elements in the list that come before the specified global ID. 42 | before: String 43 | ): ViolationsConnection! 44 | } 45 | 46 | # An edge in a connection. 47 | type InspectionEdge { 48 | # The item at the end of the edge. 49 | node: Inspection 50 | 51 | # A cursor for use in pagination. 52 | cursor: String! 53 | } 54 | 55 | # The connection type for Inspection. 56 | type InspectionsConnection { 57 | # A list of edges. 58 | edges: [InspectionEdge] 59 | 60 | # A list of nodes. 61 | nodes: [Inspection] 62 | 63 | # Information to aid in pagination. 64 | pageInfo: PageInfo! 65 | totalCount: Int 66 | } 67 | 68 | # An object with an ID. 69 | interface Node { 70 | # ID of the object. 71 | id: ID! 72 | } 73 | 74 | # Information about pagination in a connection. 75 | type PageInfo { 76 | # When paginating forwards, are there more items? 77 | hasNextPage: Boolean! 78 | 79 | # When paginating backwards, are there more items? 80 | hasPreviousPage: Boolean! 81 | 82 | # When paginating backwards, the cursor to continue. 83 | startCursor: String 84 | 85 | # When paginating forwards, the cursor to continue. 86 | endCursor: String 87 | } 88 | 89 | # A place of business serving food in New York City 90 | type Restaurant implements Node { 91 | id: ID! 92 | 93 | # The doing-business-as value. 94 | name: String! 95 | 96 | # The unique identifier. 97 | camis: String! 98 | 99 | # The address of the restaurant. 100 | address: String 101 | 102 | # The phone number. 103 | phoneNumber: String 104 | 105 | # The cuisine. 106 | cuisine: String 107 | 108 | # The latest grade of an inspection. 109 | grade: String 110 | borough: RestaurantBorough 111 | 112 | # List the inspections. 113 | inspections: [Inspection] 114 | 115 | # The inspections of the restaurant as a Relay connection. 116 | paginatedInspections( 117 | # Returns the first _n_ elements from the list. 118 | first: Int 119 | 120 | # Returns the elements in the list that come after the specified global ID. 121 | after: String 122 | 123 | # Returns the last _n_ elements from the list. 124 | last: Int 125 | 126 | # Returns the elements in the list that come before the specified global ID. 127 | before: String 128 | ): InspectionsConnection 129 | } 130 | 131 | # The borough in which the Restaurant resides. 132 | enum RestaurantBorough { 133 | # Bronx 134 | BRONX 135 | 136 | # Brooklyn 137 | BROOKLYN 138 | 139 | # Manhattan 140 | MANHATTAN 141 | 142 | # Staten Island 143 | STATEN_ISLAND 144 | 145 | # Queens 146 | QUEENS 147 | } 148 | 149 | # An edge in a connection. 150 | type RestaurantEdge { 151 | # The item at the end of the edge. 152 | node: Restaurant 153 | 154 | # A cursor for use in pagination. 155 | cursor: String! 156 | } 157 | 158 | # The connection type for Restaurant. 159 | type RestaurantsConnection { 160 | # A list of edges. 161 | edges: [RestaurantEdge] 162 | 163 | # A list of nodes. 164 | nodes: [Restaurant] 165 | 166 | # Information to aid in pagination. 167 | pageInfo: PageInfo! 168 | totalCount: Int 169 | } 170 | 171 | # The query root. 172 | type RootQuery { 173 | # Fetches an object given its ID. 174 | node( 175 | # ID of the object. 176 | id: ID! 177 | ): Node 178 | 179 | # Perform a search for one restaurant. 180 | restaurant(name: String, borough: RestaurantBorough): Restaurant 181 | 182 | # Perform a search across all Restaurants. 183 | restaurants(name: String, borough: RestaurantBorough): [Restaurant]! 184 | 185 | # Perform a search across all Restaurants and return a Relay connection. 186 | paginatedRestaurants( 187 | # Returns the first _n_ elements from the list. 188 | first: Int 189 | 190 | # Returns the elements in the list that come after the specified global ID. 191 | after: String 192 | 193 | # Returns the last _n_ elements from the list. 194 | last: Int 195 | 196 | # Returns the elements in the list that come before the specified global ID. 197 | before: String 198 | name: String 199 | borough: RestaurantBorough 200 | ): RestaurantsConnection! 201 | 202 | # Perform a search across all Inspections. 203 | inspections(grade: String): [Inspection]! 204 | 205 | # Perform a search across all Inspections. 206 | paginatedInspections( 207 | # Returns the first _n_ elements from the list. 208 | first: Int 209 | 210 | # Returns the elements in the list that come after the specified global ID. 211 | after: String 212 | 213 | # Returns the last _n_ elements from the list. 214 | last: Int 215 | 216 | # Returns the elements in the list that come before the specified global ID. 217 | before: String 218 | grade: String 219 | ): InspectionsConnection! 220 | } 221 | 222 | # A NYC health inspection violation. 223 | type Violation implements Node { 224 | id: ID! 225 | 226 | # The description of the violation. 227 | description: String 228 | 229 | # The violation code cited. 230 | code: String 231 | 232 | # The inspection this violation was a part of. 233 | inspection: Inspection 234 | } 235 | 236 | # An edge in a connection. 237 | type ViolationEdge { 238 | # The item at the end of the edge. 239 | node: Violation 240 | 241 | # A cursor for use in pagination. 242 | cursor: String! 243 | } 244 | 245 | # The connection type for Violation. 246 | type ViolationsConnection { 247 | # A list of edges. 248 | edges: [ViolationEdge] 249 | 250 | # A list of nodes. 251 | nodes: [Violation] 252 | 253 | # Information to aid in pagination. 254 | pageInfo: PageInfo! 255 | totalCount: Int 256 | } 257 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.2.1) 5 | actionpack (= 5.2.1) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailer (5.2.1) 9 | actionpack (= 5.2.1) 10 | actionview (= 5.2.1) 11 | activejob (= 5.2.1) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.2.1) 15 | actionview (= 5.2.1) 16 | activesupport (= 5.2.1) 17 | rack (~> 2.0) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.2.1) 22 | activesupport (= 5.2.1) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.2.1) 28 | activesupport (= 5.2.1) 29 | globalid (>= 0.3.6) 30 | activemodel (5.2.1) 31 | activesupport (= 5.2.1) 32 | activerecord (5.2.1) 33 | activemodel (= 5.2.1) 34 | activesupport (= 5.2.1) 35 | arel (>= 9.0) 36 | activerecord-import (0.25.0) 37 | activerecord (>= 3.2) 38 | activestorage (5.2.1) 39 | actionpack (= 5.2.1) 40 | activerecord (= 5.2.1) 41 | marcel (~> 0.3.1) 42 | activesupport (5.2.1) 43 | concurrent-ruby (~> 1.0, >= 1.0.2) 44 | i18n (>= 0.7, < 2) 45 | minitest (~> 5.1) 46 | tzinfo (~> 1.1) 47 | addressable (2.5.2) 48 | public_suffix (>= 2.0.2, < 4.0) 49 | archive-zip (0.11.0) 50 | io-like (~> 0.3.0) 51 | arel (9.0.0) 52 | bindex (0.5.0) 53 | bootsnap (1.3.1) 54 | msgpack (~> 1.0) 55 | builder (3.2.3) 56 | byebug (10.0.2) 57 | capybara (3.6.0) 58 | addressable 59 | mini_mime (>= 0.1.3) 60 | nokogiri (~> 1.8) 61 | rack (>= 1.6.0) 62 | rack-test (>= 0.6.3) 63 | xpath (~> 3.1) 64 | childprocess (0.9.0) 65 | ffi (~> 1.0, >= 1.0.11) 66 | chromedriver-helper (1.2.0) 67 | archive-zip (~> 0.10) 68 | nokogiri (~> 1.8) 69 | coderay (1.1.2) 70 | coffee-rails (4.2.2) 71 | coffee-script (>= 2.2.0) 72 | railties (>= 4.0.0) 73 | coffee-script (2.4.1) 74 | coffee-script-source 75 | execjs 76 | coffee-script-source (1.12.2) 77 | concurrent-ruby (1.0.5) 78 | connection_pool (2.2.2) 79 | crass (1.0.4) 80 | domain_name (0.5.20180417) 81 | unf (>= 0.0.5, < 1.0.0) 82 | erubi (1.7.1) 83 | execjs (2.7.0) 84 | ffi (1.9.25) 85 | globalid (0.4.1) 86 | activesupport (>= 4.2.0) 87 | graphiql-rails (1.4.11) 88 | railties 89 | sprockets-rails 90 | graphql (1.8.7) 91 | graphql-batch (0.3.10) 92 | graphql (>= 0.8, < 2) 93 | promise.rb (~> 0.7.2) 94 | http-cookie (1.0.3) 95 | domain_name (~> 0.5) 96 | i18n (1.1.0) 97 | concurrent-ruby (~> 1.0) 98 | io-like (0.3.0) 99 | jbuilder (2.7.0) 100 | activesupport (>= 4.2.0) 101 | multi_json (>= 1.2) 102 | listen (3.1.5) 103 | rb-fsevent (~> 0.9, >= 0.9.4) 104 | rb-inotify (~> 0.9, >= 0.9.7) 105 | ruby_dep (~> 1.2) 106 | loofah (2.2.2) 107 | crass (~> 1.0.2) 108 | nokogiri (>= 1.5.9) 109 | mail (2.7.0) 110 | mini_mime (>= 0.1.1) 111 | marcel (0.3.2) 112 | mimemagic (~> 0.3.2) 113 | method_source (0.9.0) 114 | mime-types (3.2.2) 115 | mime-types-data (~> 3.2015) 116 | mime-types-data (3.2018.0812) 117 | mimemagic (0.3.2) 118 | mini_mime (1.0.1) 119 | mini_portile2 (2.3.0) 120 | minitest (5.11.3) 121 | msgpack (1.2.4) 122 | multi_json (1.13.1) 123 | netrc (0.11.0) 124 | nio4r (2.3.1) 125 | nokogiri (1.8.4) 126 | mini_portile2 (~> 2.3.0) 127 | pg (0.21.0) 128 | promise.rb (0.7.4) 129 | pry (0.11.3) 130 | coderay (~> 1.1.0) 131 | method_source (~> 0.9.0) 132 | pry-rails (0.3.6) 133 | pry (>= 0.10.4) 134 | public_suffix (3.0.3) 135 | puma (3.12.0) 136 | rack (2.0.5) 137 | rack-protection (2.0.3) 138 | rack 139 | rack-test (1.1.0) 140 | rack (>= 1.0, < 3) 141 | rails (5.2.1) 142 | actioncable (= 5.2.1) 143 | actionmailer (= 5.2.1) 144 | actionpack (= 5.2.1) 145 | actionview (= 5.2.1) 146 | activejob (= 5.2.1) 147 | activemodel (= 5.2.1) 148 | activerecord (= 5.2.1) 149 | activestorage (= 5.2.1) 150 | activesupport (= 5.2.1) 151 | bundler (>= 1.3.0) 152 | railties (= 5.2.1) 153 | sprockets-rails (>= 2.0.0) 154 | rails-dom-testing (2.0.3) 155 | activesupport (>= 4.2.0) 156 | nokogiri (>= 1.6) 157 | rails-html-sanitizer (1.0.4) 158 | loofah (~> 2.2, >= 2.2.2) 159 | rails_12factor (0.0.3) 160 | rails_serve_static_assets 161 | rails_stdout_logging 162 | rails_serve_static_assets (0.0.5) 163 | rails_stdout_logging (0.0.5) 164 | railties (5.2.1) 165 | actionpack (= 5.2.1) 166 | activesupport (= 5.2.1) 167 | method_source 168 | rake (>= 0.8.7) 169 | thor (>= 0.19.0, < 2.0) 170 | rake (12.3.1) 171 | rb-fsevent (0.10.3) 172 | rb-inotify (0.9.10) 173 | ffi (>= 0.5.0, < 2) 174 | redis (4.0.2) 175 | rest-client (2.0.2) 176 | http-cookie (>= 1.0.2, < 2.0) 177 | mime-types (>= 1.16, < 4.0) 178 | netrc (~> 0.8) 179 | ruby_dep (1.5.0) 180 | rubyzip (1.2.1) 181 | sass (3.5.7) 182 | sass-listen (~> 4.0.0) 183 | sass-listen (4.0.0) 184 | rb-fsevent (~> 0.9, >= 0.9.4) 185 | rb-inotify (~> 0.9, >= 0.9.7) 186 | sass-rails (5.0.7) 187 | railties (>= 4.0.0, < 6) 188 | sass (~> 3.1) 189 | sprockets (>= 2.8, < 4.0) 190 | sprockets-rails (>= 2.0, < 4.0) 191 | tilt (>= 1.1, < 3) 192 | selenium-webdriver (3.14.0) 193 | childprocess (~> 0.5) 194 | rubyzip (~> 1.2) 195 | sidekiq (5.2.1) 196 | connection_pool (~> 2.2, >= 2.2.2) 197 | rack-protection (>= 1.5.0) 198 | redis (>= 3.3.5, < 5) 199 | spring (2.0.2) 200 | activesupport (>= 4.2) 201 | spring-watcher-listen (2.0.1) 202 | listen (>= 2.7, < 4.0) 203 | spring (>= 1.2, < 3.0) 204 | sprockets (3.7.2) 205 | concurrent-ruby (~> 1.0) 206 | rack (> 1, < 3) 207 | sprockets-rails (3.2.1) 208 | actionpack (>= 4.0) 209 | activesupport (>= 4.0) 210 | sprockets (>= 3.0.0) 211 | thor (0.20.0) 212 | thread_safe (0.3.6) 213 | tilt (2.0.8) 214 | turbolinks (5.2.0) 215 | turbolinks-source (~> 5.2) 216 | turbolinks-source (5.2.0) 217 | tzinfo (1.2.5) 218 | thread_safe (~> 0.1) 219 | uglifier (4.1.18) 220 | execjs (>= 0.3.0, < 3) 221 | unf (0.1.4) 222 | unf_ext 223 | unf_ext (0.0.7.5) 224 | web-console (3.6.2) 225 | actionview (>= 5.0) 226 | activemodel (>= 5.0) 227 | bindex (>= 0.4.0) 228 | railties (>= 5.0) 229 | websocket-driver (0.7.0) 230 | websocket-extensions (>= 0.1.0) 231 | websocket-extensions (0.1.3) 232 | xpath (3.1.0) 233 | nokogiri (~> 1.8) 234 | 235 | PLATFORMS 236 | ruby 237 | 238 | DEPENDENCIES 239 | activerecord-import 240 | bootsnap (>= 1.1.0) 241 | byebug 242 | capybara (>= 2.15) 243 | chromedriver-helper 244 | coffee-rails (~> 4.2) 245 | graphiql-rails 246 | graphql 247 | graphql-batch 248 | jbuilder (~> 2.5) 249 | listen (>= 3.0.5, < 3.2) 250 | pg (~> 0.21) 251 | pry-rails 252 | puma (~> 3.11) 253 | rails (~> 5.2.1) 254 | rails_12factor 255 | rest-client 256 | sass-rails (~> 5.0) 257 | selenium-webdriver 258 | sidekiq 259 | spring 260 | spring-watcher-listen (~> 2.0.0) 261 | turbolinks (~> 5) 262 | tzinfo-data 263 | uglifier (>= 1.3.0) 264 | web-console (>= 3.3.0) 265 | 266 | RUBY VERSION 267 | ruby 2.5.1p57 268 | 269 | BUNDLED WITH 270 | 1.16.3 271 | --------------------------------------------------------------------------------