From 2f4095fbb11585cce80769101df8d56ab7173255 Mon Sep 17 00:00:00 2001 From: Slava Zalygin Date: Fri, 26 Jul 2024 12:35:39 +0300 Subject: [PATCH] fix traefik and codestyle (#59) --- _Gemfile.lock | 386 ---------------------- app/api/vk.rb | 6 +- app/controllers/admin/users_controller.rb | 84 +++-- app/controllers/home_controller.rb | 14 +- app/controllers/sessions_controller.rb | 43 ++- app/models/friend.rb | 14 +- app/models/post.rb | 25 +- app/models/user.rb | 2 +- bin/load-token | 4 +- config/deploy.yml | 4 +- config/rubocop.yml | 4 +- db/schema.rb | 122 +++---- 12 files changed, 159 insertions(+), 549 deletions(-) delete mode 100644 _Gemfile.lock diff --git a/_Gemfile.lock b/_Gemfile.lock deleted file mode 100644 index 49b6ff85..00000000 --- a/_Gemfile.lock +++ /dev/null @@ -1,386 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) - timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) - marcel (~> 1.0) - activesupport (7.1.3.4) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - administrate (0.20.1) - actionpack (>= 6.0, < 8.0) - actionview (>= 6.0, < 8.0) - activerecord (>= 6.0, < 8.0) - jquery-rails (~> 4.6.0) - kaminari (~> 1.2.2) - sassc-rails (~> 2.1) - selectize-rails (~> 0.6) - ast (2.4.2) - base64 (0.2.0) - bcrypt (3.1.20) - bigdecimal (3.1.8) - bindex (0.8.1) - bootsnap (1.18.3) - msgpack (~> 1.2) - browser (6.0.0) - builder (3.3.0) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - concurrent-ruby (1.3.3) - connection_pool (2.4.1) - crass (1.0.6) - cssbundling-rails (1.4.0) - railties (>= 6.0.0) - csv (3.3.0) - date (3.3.4) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) - devise (4.9.4) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 4.1.0) - responders - warden (~> 1.2.3) - digest (3.1.1) - drb (2.2.1) - erubi (1.13.0) - faraday (2.10.0) - faraday-net_http (>= 2.0, < 3.2) - logger - faraday-net_http (3.1.0) - net-http - ffi (1.16.3) - ffi (1.16.3-x64-mingw-ucrt) - globalid (1.2.1) - activesupport (>= 6.1) - httparty (0.22.0) - csv - mini_mime (>= 1.0.0) - multi_xml (>= 0.5.2) - i18n (1.14.5) - concurrent-ruby (~> 1.0) - importmap-rails (2.0.1) - actionpack (>= 6.0.0) - activesupport (>= 6.0.0) - railties (>= 6.0.0) - io-console (0.7.2) - irb (1.14.0) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jbuilder (2.12.0) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) - jquery-rails (4.6.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json (2.7.2) - kaminari (1.2.2) - activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.2) - kaminari-activerecord (= 1.2.2) - kaminari-core (= 1.2.2) - kaminari-actionview (1.2.2) - actionview - kaminari-core (= 1.2.2) - kaminari-activerecord (1.2.2) - activerecord - kaminari-core (= 1.2.2) - kaminari-core (1.2.2) - language_server-protocol (3.17.0.3) - logger (1.6.0) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - matrix (0.4.2) - mini_mime (1.1.5) - minitest (5.24.1) - msgpack (1.7.2) - multi_xml (0.7.1) - bigdecimal (~> 3.1) - mutex_m (0.2.0) - net-http (0.4.1) - uri - net-imap (0.4.14) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.0) - net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-x64-mingw-ucrt) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) - racc (~> 1.4) - orm_adapter (0.5.0) - parallel (1.25.1) - parser (3.3.4.0) - ast (~> 2.4.1) - racc - pg (1.5.6) - pg (1.5.6-x64-mingw-ucrt) - pkce_challenge (1.0.0) - psych (5.1.2) - stringio - public_suffix (6.0.0) - puma (6.4.2) - nio4r (~> 2.0) - racc (1.8.0) - rack (3.1.7) - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - bundler (>= 1.15.0) - railties (= 7.1.3.4) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - rails_performance (1.2.2) - browser - railties - redis - redis-namespace - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rainbow (3.1.1) - rake (13.2.1) - rdoc (6.7.0) - psych (>= 4.0.0) - redis (5.2.0) - redis-client (>= 0.22.0) - redis-client (0.22.2) - connection_pool - redis-namespace (1.11.0) - redis (>= 4) - regexp_parser (2.9.2) - reline (0.5.9) - io-console (~> 0.5) - responders (3.1.1) - actionpack (>= 5.2) - railties (>= 5.2) - rexml (3.3.2) - strscan - rubocop (1.65.0) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) - ruby-progressbar (1.13.0) - rubyzip (2.3.2) - sassc (2.4.0) - ffi (~> 1.9) - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt - selectize-rails (0.12.6) - selenium-webdriver (4.23.0) - base64 (~> 0.2) - logger (~> 1.4) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - stimulus-rails (1.3.3) - railties (>= 6.0.0) - stringio (3.1.1) - strscan (3.1.0) - thor (1.3.1) - tilt (2.4.0) - timeout (0.4.1) - turbo-rails (2.0.6) - actionpack (>= 6.0.0) - activejob (>= 6.0.0) - railties (>= 6.0.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - tzinfo-data (1.2024.1) - tzinfo (>= 1.0.0) - unicode-display_width (2.5.0) - uri (0.13.0) - warden (1.2.9) - rack (>= 2.0.9) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - webrick (1.8.1) - websocket (1.2.11) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - zeitwerk (2.6.16) - -PLATFORMS - x64-mingw-ucrt - x86_64-darwin-23 - x86_64-linux - -DEPENDENCIES - administrate - bootsnap - capybara - cssbundling-rails - debug - devise - digest - faraday - ffi (~> 1.16.3) - httparty - importmap-rails (~> 2.0.1) - jbuilder - pg (~> 1.1) - pkce_challenge - puma (>= 5.0) - rack (~> 3.1.7) - rack-session (~> 2.0.0) - rackup (~> 2.1.0) - rails (~> 7.1.3, >= 7.1.3.4) - rails_performance - rubocop (~> 1.65) - selenium-webdriver (~> 4.23.0) - sprockets-rails - stimulus-rails - turbo-rails (~> 2.0.6) - tzinfo-data - web-console - -RUBY VERSION - ruby 3.2.4p170 - -BUNDLED WITH - 2.4.19 diff --git a/app/api/vk.rb b/app/api/vk.rb index c54fb4f6..dec06812 100644 --- a/app/api/vk.rb +++ b/app/api/vk.rb @@ -108,7 +108,7 @@ def self.get_profile_info(user) resp.body['response'][0] end - def self.get_data(user) # rubocop:disable Metrics/AbcSize + def self.get_data(user) resp = try_request(:get, '/method/wall.get', { access_token: user.access_token, @@ -120,7 +120,7 @@ def self.get_data(user) # rubocop:disable Metrics/AbcSize post_data_all = resp.body['response']['items'] post_data_all.map do |post_data| like_count = post_data['likes']['count'] - comment_count = post_data['comments']['count'] + post_data['comments']['count'] post_likers = if like_count.zero? [] @@ -156,7 +156,7 @@ def self.get_image_from_post(post_media) image_url end - def self.find_image_from_media(media) # rubocop:disable Metrics/AbcSize + def self.find_image_from_media(media) case media['type'] when 'photo' return find_image_of_size(media['photo']['sizes']) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index cb92e54a..8465b413 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,50 +1,48 @@ # frozen_string_literal: true -# # frozen_string_literal: true +module Admin + class UsersController < Admin::ApplicationController + # Overwrite any of the RESTful controller actions to implement custom behavior + # For example, you may want to send an email after a foo is updated. + # + # def update + # super + # send_foo_updated_email(requested_resource) + # end -# module Admin -# class UsersController < Admin::ApplicationController -# # Overwrite any of the RESTful controller actions to implement custom behavior -# # For example, you may want to send an email after a foo is updated. -# # -# # def update -# # super -# # send_foo_updated_email(requested_resource) -# # end + # Override this method to specify custom lookup behavior. + # This will be used to set the resource for the `show`, `edit`, and `update` + # actions. + # + # def find_resource(param) + # Foo.find_by!(slug: param) + # end -# # Override this method to specify custom lookup behavior. -# # This will be used to set the resource for the `show`, `edit`, and `update` -# # actions. -# # -# # def find_resource(param) -# # Foo.find_by!(slug: param) -# # end + # The result of this lookup will be available as `requested_resource` -# # The result of this lookup will be available as `requested_resource` + # Override this if you have certain roles that require a subset + # this will be used to set the records shown on the `index` action. + # + # def scoped_resource + # if current_user.super_admin? + # resource_class + # else + # resource_class.with_less_stuff + # end + # end -# # Override this if you have certain roles that require a subset -# # this will be used to set the records shown on the `index` action. -# # -# # def scoped_resource -# # if current_user.super_admin? -# # resource_class -# # else -# # resource_class.with_less_stuff -# # end -# # end + # Override `resource_params` if you want to transform the submitted + # data before it's persisted. For example, the following would turn all + # empty values into nil values. It uses other APIs such as `resource_class` + # and `dashboard`: + # + # def resource_params + # params.require(resource_class.model_name.param_key). + # permit(dashboard.permitted_attributes(action_name)). + # transform_values { |value| value == "" ? nil : value } + # end -# # Override `resource_params` if you want to transform the submitted -# # data before it's persisted. For example, the following would turn all -# # empty values into nil values. It uses other APIs such as `resource_class` -# # and `dashboard`: -# # -# # def resource_params -# # params.require(resource_class.model_name.param_key). -# # permit(dashboard.permitted_attributes(action_name)). -# # transform_values { |value| value == "" ? nil : value } -# # end - -# # See https://administrate-demo.herokuapp.com/customizing_controller_actions -# # for more information -# end -# end + # See https://administrate-demo.herokuapp.com/customizing_controller_actions + # for more information + end +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 91d9448a..3184327e 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,12 +2,12 @@ class HomeController < ApplicationController def index - unless current_user - pkce_challenge = PkceChallenge.challenge - session[:code_verifier] = pkce_challenge.code_verifier - @data_attributes = { - challenge: pkce_challenge.code_challenge, state: session.id.public_id - }.to_json - end + return if current_user + + pkce_challenge = PkceChallenge.challenge + session[:code_verifier] = pkce_challenge.code_verifier + @data_attributes = { + challenge: pkce_challenge.code_challenge, state: session.id.public_id + }.to_json end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1cc2a3ae..63a6e470 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -15,7 +15,7 @@ def create # rubocop:disable Metrics/AbcSize response = Vk.exchange_code(params['code'], session[:code_verifier], params['device_id'], params['state']) # поиск пользователя или создание его user = User.user_create(response.merge({ deviceid: params['device_id'], state: params['state'] })) - user.link_friends Vk.get_friends(user).map { |h| Friend.from_vk h } + user.link_friends(Vk.get_friends(user).map { |h| Friend.from_vk h }) Vk.get_data(user).map { |h| Post.from_vk h, user } MetricsCalculator.call user sign_in user @@ -39,29 +39,28 @@ def view # rubocop:disable Metrics/AbcSize end end - # rubocop:disable Metrics/AbcSize def index - if user.update_metrics_needed? - user.update_metrics - MetricsCalculator.call(user) + return unless user.update_metrics_needed? + + user.update_metrics + MetricsCalculator.call(user) + + @metrics = { + friends: user.friends.count, + active_friends: user.active_friends.count, + inactive_friends: user.inactive_friends.count, + average_likes: user.metric.average_likes, + target_likes: user.metric.target_likes, + average_comments: user.metric.average_comments, + target_comments: user.metric.target_comments, + comments_likes_ratio: user.metric.comments_likes_ratio, + target_comments_likes_ratio: user.metric.target_comments_likes_ratio, + average_engagement_score: user.metric.average_engagement_score, + audience_score: user.metric.audience_score, + active_friends_percentage: (user.active_friends.count.to_f / user.friends.count * 100).round(2), + inactive_friends_percentage: (user.inactive_friends.count.to_f / user.friends.count * 100).round(2) + } - @metrics = { - friends: user.friends.count, - active_friends: user.active_friends.count, - inactive_friends: user.inactive_friends.count, - average_likes: user.metric.average_likes, - target_likes: user.metric.target_likes, - average_comments: user.metric.average_comments, - target_comments: user.metric.target_comments, - comments_likes_ratio: user.metric.comments_likes_ratio, - target_comments_likes_ratio: user.metric.target_comments_likes_ratio, - average_engagement_score: user.metric.average_engagement_score, - audience_score: user.metric.audience_score, - active_friends_percentage: (user.active_friends.count.to_f / user.friends.count * 100).round(2), - inactive_friends_percentage: (user.inactive_friends.count.to_f / user.friends.count * 100).round(2) - } - end # rubocop:enable Metrics/AbcSize end end -# rubocop:enable Lint/NestedMethodDefinition diff --git a/app/models/friend.rb b/app/models/friend.rb index f6a3ed5a..a9c032c6 100644 --- a/app/models/friend.rb +++ b/app/models/friend.rb @@ -9,16 +9,16 @@ class Friend < ApplicationRecord # validates :vk_uid, presence: true, uniqueness: true def self.from_vk(payload) - existing_friend=find_or_create_by(vk_uid: payload["id"]) do |friend| + existing_friend = find_or_create_by(vk_uid: payload['id']) do |friend| # friend.vk_uid = payload[:id], - friend.first_name =payload['first_name'], - friend.last_name = payload['last_name'], - friend.image_url = payload['photo_50'] + friend.first_name = payload['first_name'], + friend.last_name = payload['last_name'], + friend.image_url = payload['photo_50'] end existing_friend.update( - first_name: payload['first_name'], - last_name: payload['last_name'], - image_url: payload['photo_50'] + first_name: payload['first_name'], + last_name: payload['last_name'], + image_url: payload['photo_50'] ) existing_friend end diff --git a/app/models/post.rb b/app/models/post.rb index 8b75a371..9c73e2f0 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -8,23 +8,24 @@ class Post < ApplicationRecord def self.from_vk(payload, owner) puts 'PAYLOAD!!!' puts payload - existing_post= find_or_create_by(vk_uid: payload[:post_id]) do |post| + existing_post = find_or_create_by(vk_uid: payload[:post_id]) do |post| # post.vk_uid = payload[:post_id], post.date = payload[:date], - post.image_url = payload[:image_url], - # post.count_likes = payload[:count_likes], - # post.count_comments = payload[:count_comments], - post.likes = payload[:likers], - post.comments = payload[:commentators] + post.image_url = payload[:image_url], + # post.count_likes = payload[:count_likes], + # post.count_comments = payload[:count_comments], + post.likes = payload[:likers], + post.comments = payload[:commentators] post.user = owner end existing_post.update( - date: payload[:date], - image_url: payload[:image_url], - # count_likes: payload[:count_likes], - # count_comments: payload[:count_comments], - likes: payload[:likers], - comments: payload[:commentators]) + date: payload[:date], + image_url: payload[:image_url], + # count_likes: payload[:count_likes], + # count_comments: payload[:count_comments], + likes: payload[:likers], + comments: payload[:commentators] + ) existing_post end end diff --git a/app/models/user.rb b/app/models/user.rb index 85a71bbb..f4b7418f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -70,7 +70,7 @@ def self.needs_refresh_token?(user) Time.now > user.access_token_expiration_time end - def self.user_create(response) # rubocop:disable Metrics/AbcSize + def self.user_create(response) user = User.find_or_create_by(user_id: response['user_id']) do |u| u.access_token = response['access_token'] u.refresh_token = response['refresh_token'] diff --git a/bin/load-token b/bin/load-token index febedb2f..2bc61033 100755 --- a/bin/load-token +++ b/bin/load-token @@ -1,5 +1,5 @@ -# frozen_string_literal: true #!/usr/bin/env ruby +# frozen_string_literal: true # A sample pre-deploy hook # @@ -28,7 +28,7 @@ require 'jwt' require 'json' require 'time' -KEY_FILE = 'config/authorized_key.json'.freeze +KEY_FILE = 'config/authorized_key.json' KEY_DATA = JSON.parse(File.read(KEY_FILE)) KEY_ID = KEY_DATA['id'] SERVICE_ACCOUNT_ID = KEY_DATA['service_account_id'] diff --git a/config/deploy.yml b/config/deploy.yml index 55dc7b4b..a9790e7e 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -15,7 +15,7 @@ servers: traefik.http.routers.taska_secure.entrypoints: websecure traefik.http.routers.taska_secure.rule: Host(`wheremylikes.com`) traefik.http.routers.taska_secure.tls: true - traefik.http.routers.taska_secure.tls.certresolver: letsencrypt + traefik.http.routers.taska_secure.tls.certResolver: letsencrypt options: network: "private" @@ -107,8 +107,6 @@ traefik: certificatesResolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json" # Must match the path in `volume` certificatesResolvers.letsencrypt.acme.httpchallenge: true certificatesResolvers.letsencrypt.acme.httpchallenge.entrypoint: web # Must match the role in `servers` - accesslog: true - accesslog.format: json # Configure a custom healthcheck (default is /up on port 3000) # healthcheck: diff --git a/config/rubocop.yml b/config/rubocop.yml index 491f5211..436272de 100644 --- a/config/rubocop.yml +++ b/config/rubocop.yml @@ -17,6 +17,4 @@ Style/Documentation: Enabled: false Metrics/AbcSize: - Enabled: true - Exclude: - - "app/services/metrics_calculator.rb" + Enabled: false diff --git a/db/schema.rb b/db/schema.rb index ebe171d5..12367906 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,76 +12,76 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_07_24_080223) do +ActiveRecord::Schema[7.1].define(version: 20_240_724_080_223) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension 'plpgsql' - create_table "friends", force: :cascade do |t| - t.integer "vk_uid" - t.text "first_name" - t.text "last_name" - t.text "image_url" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["vk_uid"], name: "index_friends_on_vk_uid", unique: true + create_table 'friends', force: :cascade do |t| + t.integer 'vk_uid' + t.text 'first_name' + t.text 'last_name' + t.text 'image_url' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['vk_uid'], name: 'index_friends_on_vk_uid', unique: true end - create_table "metrics", force: :cascade do |t| - t.integer "average_likes" - t.integer "target_likes" - t.integer "average_comments" - t.integer "target_comments" - t.integer "comments_likes_ratio" - t.integer "target_comments_likes_ratio" - t.decimal "audience_score" - t.integer "average_engagement_rate" - t.bigint "user_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["user_id"], name: "index_metrics_on_user_id" + create_table 'metrics', force: :cascade do |t| + t.integer 'average_likes' + t.integer 'target_likes' + t.integer 'average_comments' + t.integer 'target_comments' + t.integer 'comments_likes_ratio' + t.integer 'target_comments_likes_ratio' + t.decimal 'audience_score' + t.integer 'average_engagement_rate' + t.bigint 'user_id', null: false + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['user_id'], name: 'index_metrics_on_user_id' end - create_table "posts", force: :cascade do |t| - t.integer "vk_uid" - t.integer "date" - t.text "image_url" - t.integer "likes", array: true - t.integer "comments", array: true - t.integer "engagement_rate" - t.bigint "user_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["user_id"], name: "index_posts_on_user_id" - t.index ["vk_uid"], name: "index_posts_on_vk_uid", unique: true + create_table 'posts', force: :cascade do |t| + t.integer 'vk_uid' + t.integer 'date' + t.text 'image_url' + t.integer 'likes', array: true + t.integer 'comments', array: true + t.integer 'engagement_rate' + t.bigint 'user_id', null: false + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['user_id'], name: 'index_posts_on_user_id' + t.index ['vk_uid'], name: 'index_posts_on_vk_uid', unique: true end - create_table "relationships", force: :cascade do |t| - t.bigint "user_id" - t.bigint "friend_id" - t.boolean "active", default: true - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["friend_id", "user_id"], name: "index_relationships_on_friend_id_and_user_id" - t.index ["friend_id"], name: "index_relationships_on_friend_id" - t.index ["user_id", "friend_id"], name: "index_relationships_on_user_id_and_friend_id" - t.index ["user_id"], name: "index_relationships_on_user_id" + create_table 'relationships', force: :cascade do |t| + t.bigint 'user_id' + t.bigint 'friend_id' + t.boolean 'active', default: true + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index %w[friend_id user_id], name: 'index_relationships_on_friend_id_and_user_id' + t.index ['friend_id'], name: 'index_relationships_on_friend_id' + t.index %w[user_id friend_id], name: 'index_relationships_on_user_id_and_friend_id' + t.index ['user_id'], name: 'index_relationships_on_user_id' end - create_table "users", force: :cascade do |t| - t.string "email", default: "" - t.string "encrypted_password", default: "" - t.string "access_token", default: "", null: false - t.string "refresh_token", default: "", null: false - t.integer "user_id", null: false - t.datetime "remember_created_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "admin", default: false - t.datetime "access_token_expiration_time" - t.string "user_device_id" - t.string "user_state" + create_table 'users', force: :cascade do |t| + t.string 'email', default: '' + t.string 'encrypted_password', default: '' + t.string 'access_token', default: '', null: false + t.string 'refresh_token', default: '', null: false + t.integer 'user_id', null: false + t.datetime 'remember_created_at' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.boolean 'admin', default: false + t.datetime 'access_token_expiration_time' + t.string 'user_device_id' + t.string 'user_state' end - add_foreign_key "metrics", "users" - add_foreign_key "posts", "users" + add_foreign_key 'metrics', 'users' + add_foreign_key 'posts', 'users' end