From f83800f1c869696267cdce321b76f4f7cc07e56e Mon Sep 17 00:00:00 2001 From: KvngJamesNG Date: Tue, 29 Oct 2024 15:53:05 +0000 Subject: [PATCH 1/4] Get API --- app/controllers/cities_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app/controllers/cities_controller.rb diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb new file mode 100644 index 0000000..8f59e48 --- /dev/null +++ b/app/controllers/cities_controller.rb @@ -0,0 +1,7 @@ +class CitiesController < ApplicationController + def index + cities = Address.select(:city).distinct.pluck(:city) + render json: cities + + end +end From 82c5b88c093cf256d3e4e431e0baf069f57d1afe Mon Sep 17 00:00:00 2001 From: KvngJamesNG Date: Tue, 29 Oct 2024 22:34:26 +0000 Subject: [PATCH 2/4] missed out the routing --- app/controllers/cities_controller.rb | 1 - config/routes.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb index 8f59e48..a8a3161 100644 --- a/app/controllers/cities_controller.rb +++ b/app/controllers/cities_controller.rb @@ -2,6 +2,5 @@ class CitiesController < ApplicationController def index cities = Address.select(:city).distinct.pluck(:city) render json: cities - end end diff --git a/config/routes.rb b/config/routes.rb index 7703399..93b7910 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ registration: 'signup' } # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - + get 'cities', to: 'cities#index' # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check From 63b1607ed8bb97174a59d00250dee7df1350073b Mon Sep 17 00:00:00 2001 From: KvngJamesNG Date: Wed, 6 Nov 2024 23:36:39 +0000 Subject: [PATCH 3/4] revert --- app/controllers/cities_controller.rb | 6 ------ app/models/review.rb | 2 +- config/credentials.yml.enc | 2 +- config/routes.rb | 2 +- db/schema.rb | 5 ++++- db/seeds.rb | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) delete mode 100644 app/controllers/cities_controller.rb diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb deleted file mode 100644 index a8a3161..0000000 --- a/app/controllers/cities_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class CitiesController < ApplicationController - def index - cities = Address.select(:city).distinct.pluck(:city) - render json: cities - end -end diff --git a/app/models/review.rb b/app/models/review.rb index 57fb73e..208ec62 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -1,4 +1,4 @@ class Review < ApplicationRecord belongs_to :patient_profile belongs_to :doctor_profile -end +end \ No newline at end of file diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 4baedbb..56e5146 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -LspezHxBXYYDjpJT6leazJwF4EBpyRhnCx7dMpAFB1/Zs/gxpLSkWJLwUXqix1VSfvGf0MQ2mdlhlSpL/eawUhSaB08jEcnk1QZVb8FrOXhdL/0YzxAxSwkOfaVQUh+cbFjPWnLkjCVVzb1rJ7U8hJ1F127ELhAz7z0vdpV07aNyc3QEjujZSL412DGe0mJDttEqMvv7OKXEkLtmlZX3/LDtM8W8M/6BjJmTFHUs/2TuarmFv9InJTtVamgI1Owhp52suRDKNw7BAInBbcCZheC0vKvptUCfxUFd2a2yWqD5W3RATzKmy5v03O8vLRCmzbq8fiq87K2bYQVnw0DLja80TDt/U5Q4lLVvMUnVBRpqeW+hZKSlI2R4aVZysPBIdttsetWvwBfGtVKrHN29w/d+9lfq--qC55RquQklVlF31K--DbXL0CO115WRkLbEhR5tSQ== \ No newline at end of file +Zl4B34n6udhcvb6gaFCQS3ZHG7dShpog/OROmcAtpMzDhpMko/+z4qNsFMLjTHEzDgBKXbSGqY+ZZszMO51OYU9DM4gFcECsB9McwNwMJ5g7q4rCK6Afp5DkMO84ol/EnJuMmm4VjFTNznbXii2n/fvgYXcNPExrhe87HQF6uXdcwEK+7rPhcWUwdwSOa1P7edKuJtP3fTvoYVFVXGLw3EnGK+9F0FE1h59Dlr31Ai7WVxSEFvbREFkw9VOeBXh1+iBB5V36O8CHefldz8Y7wHrjUQOqUlulTsBFmA5ssnf75Uq9XsLurmapCB3AFLT3MCdEYTQOb1sBUcVosJtzptNdkmbyPAkTGnr98Yk1l2iZxlOdTx5re59fFyDed7swGrsEfF8IWAhwQ17yDNp8qIlM288u--cKH1tXoTkwsxmmQE--BrEytZsW8K/4LznSy0luLw== \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 93b7910..aaf0c22 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ registration: 'signup' } # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - get 'cities', to: 'cities#index' + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check diff --git a/db/schema.rb b/db/schema.rb index 50b2b64..dab1c68 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_10_25_084443) do +ActiveRecord::Schema[7.1].define(version: 2024_10_29_230329) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -118,6 +118,8 @@ t.bigint "doctor_profile_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "rating" + t.string "comment", limit: 500 t.index ["doctor_profile_id"], name: "index_reviews_on_doctor_profile_id" t.index ["patient_profile_id"], name: "index_reviews_on_patient_profile_id" end @@ -177,6 +179,7 @@ add_foreign_key "doctor_profiles", "specializations" add_foreign_key "establishments", "addresses" add_foreign_key "patient_profiles", "addresses" + add_foreign_key "payments", "appointments" add_foreign_key "reviews", "doctor_profiles" add_foreign_key "reviews", "patient_profiles" add_foreign_key "services", "doctor_profiles" diff --git a/db/seeds.rb b/db/seeds.rb index 36e97af..8954e5b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -163,4 +163,4 @@ doctor_profile: doctor_profile, jti: SecureRandom.uuid ) -end +end \ No newline at end of file From 0e579b7c7b9553b56840b6851991666b9a2c134b Mon Sep 17 00:00:00 2001 From: KvngJamesNG Date: Sun, 17 Nov 2024 23:01:36 +0000 Subject: [PATCH 4/4] Refix --- app/controllers/api/v1/cities_controller.rb | 12 ++++++++++++ config/routes.rb | 6 ++++++ db/seeds.rb | 20 +++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/controllers/api/v1/cities_controller.rb diff --git a/app/controllers/api/v1/cities_controller.rb b/app/controllers/api/v1/cities_controller.rb new file mode 100644 index 0000000..9fd7f66 --- /dev/null +++ b/app/controllers/api/v1/cities_controller.rb @@ -0,0 +1,12 @@ +module Api + module V1 + class CitiesController < ApplicationController + + def index + cities = Establishment.select(:city).distinct.where.not(city: nil).pluck(:city) + render json: cities.map { |city| { city_name: city } } + end + + end + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index aaf0c22..7b37a17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,4 +15,10 @@ # Defines the root path route ("/") # root "posts#index" + + namespace :api do + namespace :v1 do + resources :cities, only: [:index] + end + end end diff --git a/db/seeds.rb b/db/seeds.rb index 8954e5b..1a30719 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -63,6 +63,23 @@ 'West Bengal Medical Council' ] +cities = [ +"Mumbai", "Delhi", "Bangalore", "Hyderabad", "Ahmedabad", "Chennai", + "Kolkata", "Surat", "Pune", "Jaipur", "Lucknow", "Kanpur", "Nagpur", + "Indore", "Thane", "Bhopal", "Visakhapatnam", "Patna", "Vadodara", + "Ghaziabad", "Ludhiana", "Agra", "Nashik", "Faridabad", "Meerut", + "Rajkot", "Kalyan-Dombivli", "Vasai-Virar", "Varanasi", "Srinagar", + "Aurangabad", "Dhanbad", "Amritsar", "Navi Mumbai", "Allahabad", + "Howrah", "Ranchi", "Gwalior", "Jabalpur", "Coimbatore", "Vijayawada", + "Jodhpur", "Madurai", "Raipur", "Kota", "Guwahati", "Chandigarh", + "Solapur", "Hubli–Dharwad", "Mysore", "Tiruchirappalli", "Bareilly", + "Aligarh", "Tiruppur", "Moradabad", "Jalandhar", "Bhubaneswar", + "Salem", "Warangal", "Guntur", "Bhiwandi", "Saharanpur", "Gorakhpur", + "Bikaner", "Amravati", "Noida", "Jamshedpur", "Bhilai", "Cuttack", + "Firozabad", "Kochi", "Nellore", "Bhavnagar", "Dehradun", "Durgapur", + "Asansol", "Rourkela", "Nanded", "Kolhapur", "Ajmer", "Akola" +] + degrees.each { |name| Degree.find_or_create_by!(name: name) } specializations.each { |name| Specialization.find_or_create_by!(name: name) } @@ -85,7 +102,8 @@ establishments = Array.new(20) do |index| Establishment.create!( name: Faker::Company.name, - address: addresses[index], + address_id: addresses[index].id, + city: cities.sample, latitude: Faker::Address.latitude, longitude: Faker::Address.longitude, maps_location: "https://goo.gl/maps/#{Faker::Address.street_address.gsub(' ', '-')}"