diff --git a/.env.sample b/.env.sample index 6e675ce0..4083b264 100644 --- a/.env.sample +++ b/.env.sample @@ -35,3 +35,5 @@ SITEMAP_PUBLIC_URL= OR_SR_IDENTIFIERS_EMAIL_TEMPLATE_ID= OR_SR_IDENTIFIERS_DONE_EMAIL_TEMPLATE_ID= + +DATAHUB_DATABASE_URL= diff --git a/Gemfile.lock b/Gemfile.lock index cc9c472f..281110b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,22 +153,6 @@ GEM ffi-compiler (1.0.1) ffi (>= 1.0.0) rake - fog-aws (3.14.0) - fog-core (~> 2.1) - fog-json (~> 1.1) - fog-xml (~> 0.1) - fog-core (2.3.0) - builder - excon (~> 0.71) - formatador (>= 0.2, < 2.0) - mime-types - fog-json (1.2.0) - fog-core - multi_json (~> 1.10) - fog-xml (0.1.4) - fog-core - nokogiri (>= 1.5.11, < 2.0.0) - formatador (1.1.0) friendly_id (5.4.2) activerecord (>= 4.0.0) globalid (1.0.0) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb new file mode 100644 index 00000000..c2e465ea --- /dev/null +++ b/app/controllers/dashboards_controller.rb @@ -0,0 +1,6 @@ +class DashboardsController < ApplicationController + before_action :require_user + + def show + end +end diff --git a/app/models/datahub/datahub_record.rb b/app/models/datahub/datahub_record.rb new file mode 100644 index 00000000..1b875e4f --- /dev/null +++ b/app/models/datahub/datahub_record.rb @@ -0,0 +1,11 @@ +module Datahub + class DatahubRecord < ActiveRecord::Base + self.abstract_class = true + + connects_to database: { writing: :datahub, reading: :datahub } + + def readonly? + true + end + end +end diff --git a/app/models/datahub/socpoist/debtor.rb b/app/models/datahub/socpoist/debtor.rb new file mode 100644 index 00000000..6c893d1c --- /dev/null +++ b/app/models/datahub/socpoist/debtor.rb @@ -0,0 +1,30 @@ +module Datahub + module Socpoist + class Debtor < DatahubRecord + self.table_name = "socpoist.debtors" + + attribute :search_score, :float, default: nil + + def self.search(name, threshold = 0.5) + table = self.arel_table + similarity_condition = lambda do + Arel::Nodes::NamedFunction.new("similarity", + [ + Arel::Nodes::NamedFunction.new("unaccent", [ + table[:name], + ]), + Arel::Nodes::NamedFunction.new("unaccent", [ + Arel::Nodes.build_quoted(name) + ]) + ] + ) + end + + select(similarity_condition.call.as("search_score"), table[Arel.star]) + .where(similarity_condition.call.gt(threshold)) + .order(search_score: :desc) + .limit(10) + end + end + end +end diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb new file mode 100644 index 00000000..fb8adc12 --- /dev/null +++ b/app/views/dashboards/show.html.erb @@ -0,0 +1,25 @@ +
diff --git a/config/database.yml b/config/database.yml index e42ad2f4..349c5098 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,13 +6,25 @@ default: &default pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %> development: - <<: *default - database: navody_slovensko_digital_development + primary: + <<: *default + database: navody_slovensko_digital_development + datahub: + <<: *default + url: <%= ENV['DATAHUB_DATABASE_URL'] %> test: - <<: *default - database: navody_slovensko_digital_test + primary: + <<: *default + database: navody_slovensko_digital_test + datahub: + <<: *default + url: <%= ENV['DATAHUB_DATABASE_URL'] %> production: - <<: *default - url: <%= ENV['DATABASE_URL'] %> + primary: + <<: *default + url: <%= ENV['DATABASE_URL'] %> + datahub: + <<: *default + url: <%= ENV['DATAHUB_DATABASE_URL'] %> diff --git a/config/routes.rb b/config/routes.rb index c21faebd..8074b14e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -108,6 +108,7 @@ end resources :apps, path: 'aplikacie' # faux route + resource :dashboards, path: 'osobna-zona', only: [:show] resources :user_journeys, path: 'moje-zivotne-situacie' do post :restart, on: :member, path: 'zacat-odznova' end