From 9864ebe44184b06da9d6c862fdc9f53e0bf4ac20 Mon Sep 17 00:00:00 2001 From: Celso Martins Date: Fri, 15 Sep 2023 13:41:56 -0300 Subject: [PATCH] chore: updated minor gems --- Gemfile.lock | 4 +- .../slack_configurations_controller.rb | 6 +- app/controllers/teams_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/graphql/types/teams/team_member_type.rb | 2 +- .../slack/slack_notification_service.rb | 4 +- app/services/team_service.rb | 3 +- ..._add_hours_based_payment_to_team_member.rb | 2 +- .../20190212180057_add_slug_to_demands.rb | 2 +- ...90704193534_create_jira_product_configs.rb | 2 +- ...20190723195649_add_api_token_to_company.rb | 2 +- .../20190806135316_create_memberships.rb | 2 +- .../20190812154723_create_item_assignments.rb | 2 +- ...er_month_from_team_member_to_membership.rb | 6 +- ...0130181814_add_role_to_user_and_company.rb | 1 - .../20200430140032_add_customer_to_demand.rb | 2 +- ...200615173415_add_item_assignment_effort.rb | 2 +- ...122935_rename_flow_impact_to_flow_event.rb | 2 +- ...204_remove_customer_in_product_not_null.rb | 2 +- .../20221205155616_add_slug_to_product.rb | 2 +- db/passo 1 completo.rb | 1294 ----------------- lib/tasks/consolidate_flows.rake | 8 +- .../create_initiative_consolidation.rake | 2 +- lib/tasks/create_legacy_notifications.rake | 2 +- lib/tasks/dashboards_cache_generator.rake | 2 +- lib/tasks/notifications.rake | 4 +- .../process_jira_integration_errors.rake | 2 +- lib/tasks/update_azure_accounts.rake | 2 +- lib/tasks/update_item_assignments.rake | 2 +- .../azure/azure_project_adapter_spec.rb | 8 +- .../azure/azure_work_item_adapter_spec.rb | 28 +- .../azure_work_item_updates_adapter_spec.rb | 16 +- .../azure_custom_fields_controller_spec.rb | 2 +- .../demand_transitions_controller_spec.rb | 6 +- spec/controllers/demands_controller_spec.rb | 2 +- ...a_custom_field_mappings_controller_spec.rb | 4 +- ...isk_review_action_items_controller_spec.rb | 2 +- .../risk_reviews_controller_spec.rb | 2 +- .../score_matrix_answers_controller_spec.rb | 2 +- .../score_matrix_questions_controller_spec.rb | 2 +- .../slack_configurations_controller_spec.rb | 2 +- ...am_resource_allocations_controller_spec.rb | 4 +- .../team_resources_controller_spec.rb | 2 +- spec/graphql/types/mutation_type_spec.rb | 10 +- spec/graphql/types/query_type_spec.rb | 2 +- spec/helpers/demand_blocks_helper_spec.rb | 6 +- .../contract_consolidation_job_spec.rb | 4 +- .../replenishing_consolidation_job_spec.rb | 8 +- .../slack/slack_notifications_job_spec.rb | 2 +- .../flow/contracts_flow_information_spec.rb | 2 +- spec/readers/azure/azure_reader_spec.rb | 8 +- spec/services/demand_effort_service_spec.rb | 52 +- .../slack/slack_notification_service_spec.rb | 6 +- 53 files changed, 128 insertions(+), 1424 deletions(-) delete mode 100644 db/passo 1 completo.rb diff --git a/Gemfile.lock b/Gemfile.lock index 78548ec6a..81a152588 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -240,7 +240,7 @@ GEM net-smtp (0.3.3) net-protocol netrc (0.11.0) - newrelic_rpm (9.4.2) + newrelic_rpm (9.5.0) nio4r (2.5.9) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) @@ -384,7 +384,7 @@ GEM rubocop-performance (1.19.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.21.0) + rubocop-rails (2.21.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) diff --git a/app/controllers/slack_configurations_controller.rb b/app/controllers/slack_configurations_controller.rb index 1f8539517..dc4f6939f 100644 --- a/app/controllers/slack_configurations_controller.rb +++ b/app/controllers/slack_configurations_controller.rb @@ -4,7 +4,7 @@ class SlackConfigurationsController < AuthenticatedController before_action :assign_slack_config, only: %i[edit update toggle_active destroy] def index - @slack_configurations = SlackConfiguration.all.order(:created_at) + @slack_configurations = SlackConfiguration.order(:created_at) end def new @@ -15,7 +15,7 @@ def new end def edit - @slack_configurations = SlackConfiguration.all.order(:created_at) + @slack_configurations = SlackConfiguration.order(:created_at) assign_teams assign_customers assign_stages @@ -41,7 +41,7 @@ def toggle_active end def update - @slack_configurations = SlackConfiguration.all.order(:created_at) + @slack_configurations = SlackConfiguration.order(:created_at) read_stages_in_params if @slack_configuration.update(slack_configuration_params.merge(stages_to_notify_transition: @stage_ids)) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 44f8e5e44..83177bdde 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -106,7 +106,7 @@ def build_projects_lead_time_in_time_array(executing_projects) def build_membership_lead_time_in_time_array(active_memberships) @memberships_lead_time_in_time = [] array_of_dates = [] - active_memberships.includes([:demands]).each do |membership| + active_memberships.includes([:demands]).find_each do |membership| membership_lead_times_hash = compute_membership_lead_times(membership) array_of_dates << membership_lead_times_hash[:membership_period] @memberships_lead_time_in_time << membership_lead_times_hash[:membership_data] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5a9bfad16..a144ceb6c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,7 +7,7 @@ class UsersController < AuthenticatedController def admin_dashboard @users_list = User.all.sort_by(&:full_name) - @companies_list = Company.all.order(:name) + @companies_list = Company.order(:name) end def activate_email_notifications diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index 9d5154f1d..c8756428e 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -122,7 +122,7 @@ def member_effort_data def member_effort_daily_data accumulator = last_30_days_hash - object.demand_efforts.where('start_time_to_computation >= TIMESTAMP WITH TIME ZONE :date', date: member_effort_daily_interval.iso8601).each do |effort| + object.demand_efforts.where('start_time_to_computation >= TIMESTAMP WITH TIME ZONE :date', date: member_effort_daily_interval.iso8601).find_each do |effort| accumulator[effort.start_time_to_computation.beginning_of_day.to_date.to_s] += effort.effort_value.round(2) end { x_axis: accumulator.keys, y_axis: accumulator.values } diff --git a/app/services/slack/slack_notification_service.rb b/app/services/slack/slack_notification_service.rb index 54b70cd76..73f055b9e 100644 --- a/app/services/slack/slack_notification_service.rb +++ b/app/services/slack/slack_notification_service.rb @@ -255,13 +255,13 @@ def notify_team_efficiency(slack_notifier, team, start_date, end_date, title, no return if average_team_efficiency.blank? members_efforts = average_team_efficiency[:members_efficiency].reject { |member_effort| member_effort.try(:[], :membership).try(:[], :hours_per_month).blank? && member_effort.try(:[], :membership).try(:[], :hours_per_month)&.zero? } - + return if members_efforts.blank? effort_text = title members_efforts.each_with_index do |member, index| - effort_text += "• #{medal_of_honor(index)} #{member[:membership].team_member.name} | Demandas: #{member[:cards_count]} | Horas: #{number_with_precision(member[:effort_in_month])} | Capacidade: #{member[:membership][:hours_per_month]} #{notification_period == "month" ? "| Vl Hr: #{number_with_precision(member[:value_per_hour_performed])}" : ''}\n" + effort_text += "• #{medal_of_honor(index)} #{member[:membership].team_member.name} | Demandas: #{member[:cards_count]} | Horas: #{number_with_precision(member[:effort_in_month])} | Capacidade: #{member[:membership][:hours_per_month]} #{notification_period == 'month' ? "| Vl Hr: #{number_with_precision(member[:value_per_hour_performed])}" : ''}\n" end effort_info_block = { type: 'section', text: { type: 'mrkdwn', text: effort_text } } diff --git a/app/services/team_service.rb b/app/services/team_service.rb index c590c798e..d6c9ec085 100644 --- a/app/services/team_service.rb +++ b/app/services/team_service.rb @@ -71,8 +71,7 @@ def compute_memberships_realized_hours(team, start_date, end_date) avg_hours_per_demand: membership.avg_hours_per_demand(start_date, end_date), cards_count: membership.cards_count(start_date, end_date), realized_money_in_month: membership.realized_money_in_period(start_date, end_date), member_capacity_value: membership.hours_per_month || 0, - value_per_hour_performed: calculate_hours_per_month(membership.monthly_payment, membership.effort_in_period(start_date, end_date)) - } + value_per_hour_performed: calculate_hours_per_month(membership.monthly_payment, membership.effort_in_period(start_date, end_date)) } end efficiency_data = efficiency_data.sort_by { |member_ef| member_ef[:effort_in_month] }.reverse diff --git a/db/migrate/20180215201832_add_hours_based_payment_to_team_member.rb b/db/migrate/20180215201832_add_hours_based_payment_to_team_member.rb index c17053e42..33d514e7a 100644 --- a/db/migrate/20180215201832_add_hours_based_payment_to_team_member.rb +++ b/db/migrate/20180215201832_add_hours_based_payment_to_team_member.rb @@ -7,7 +7,7 @@ def change t.decimal :total_monthly_payment end - TeamMember.all.each do |member| + TeamMember.find_each do |member| member.update(total_monthly_payment: member.monthly_payment + (member.hours_per_month * member.hour_value)) end diff --git a/db/migrate/20190212180057_add_slug_to_demands.rb b/db/migrate/20190212180057_add_slug_to_demands.rb index 994b45313..7fb99999d 100644 --- a/db/migrate/20190212180057_add_slug_to_demands.rb +++ b/db/migrate/20190212180057_add_slug_to_demands.rb @@ -11,7 +11,7 @@ def change t.integer :company_id, index: true end - Demand.all.each { |demand| demand.update(company_id: demand.project.company.id) } + Demand.find_each { |demand| demand.update(company_id: demand.project.company.id) } change_column_null :demands, :company_id, false diff --git a/db/migrate/20190704193534_create_jira_product_configs.rb b/db/migrate/20190704193534_create_jira_product_configs.rb index c2d48a510..ecc2d5a5b 100644 --- a/db/migrate/20190704193534_create_jira_product_configs.rb +++ b/db/migrate/20190704193534_create_jira_product_configs.rb @@ -37,7 +37,7 @@ def up end add_foreign_key :jira_project_configs, :jira_product_configs, column: :jira_product_config_id - Jira::JiraProjectConfig.all.each do |project_config| + Jira::JiraProjectConfig.find_each do |project_config| product_config = Jira::JiraProductConfig.where(jira_product_key: project_config.jira_project_key)&.first&.id project_config.update(jira_product_config_id: product_config) if product_config.present? end diff --git a/db/migrate/20190723195649_add_api_token_to_company.rb b/db/migrate/20190723195649_add_api_token_to_company.rb index 7c49b958d..0d199d592 100644 --- a/db/migrate/20190723195649_add_api_token_to_company.rb +++ b/db/migrate/20190723195649_add_api_token_to_company.rb @@ -6,7 +6,7 @@ def change add_index :companies, :api_token, unique: true - Company.all.each.map(&:save) + Company.find_each.map(&:save) change_column_null :companies, :api_token, false end diff --git a/db/migrate/20190806135316_create_memberships.rb b/db/migrate/20190806135316_create_memberships.rb index 243b94c1b..d20cd9e7d 100644 --- a/db/migrate/20190806135316_create_memberships.rb +++ b/db/migrate/20190806135316_create_memberships.rb @@ -19,7 +19,7 @@ def up add_foreign_key :memberships, :team_members, column: :team_member_id add_foreign_key :memberships, :teams, column: :team_id - TeamMember.all.each do |member| + TeamMember.find_each do |member| Membership.create(team_id: member.team_id, team_member_id: member.id) member.update(name: "#{member.teams.first.name} | #{member.name}") unless member.valid? member.update(company_id: Team.find_by(id: member.team_id).company_id) diff --git a/db/migrate/20190812154723_create_item_assignments.rb b/db/migrate/20190812154723_create_item_assignments.rb index d4d5f32af..f322445a2 100644 --- a/db/migrate/20190812154723_create_item_assignments.rb +++ b/db/migrate/20190812154723_create_item_assignments.rb @@ -9,7 +9,7 @@ def change t.datetime :finish_time end - ItemAssignment.all.each do |assigment| + ItemAssignment.find_each do |assigment| assigment.update(start_time: (Demand.find(assigment.demand_id).commitment_date || Demand.find(assigment.demand_id).created_date), finish_time: Demand.find(assigment.demand_id).end_date) assigment.destroy unless assigment.valid? end diff --git a/db/migrate/20190816185103_move_hours_per_month_from_team_member_to_membership.rb b/db/migrate/20190816185103_move_hours_per_month_from_team_member_to_membership.rb index 56dbf3b8e..84d493c76 100644 --- a/db/migrate/20190816185103_move_hours_per_month_from_team_member_to_membership.rb +++ b/db/migrate/20190816185103_move_hours_per_month_from_team_member_to_membership.rb @@ -8,9 +8,9 @@ def up t.date :end_date end - Membership.all.each { |membership| membership.update(hours_per_month: membership.team_member.hours_per_month, start_date: membership.team_member.start_date, end_date: membership.team_member.end_date) } + Membership.find_each { |membership| membership.update(hours_per_month: membership.team_member.hours_per_month, start_date: membership.team_member.start_date, end_date: membership.team_member.end_date) } - memberships_start_date_nil = Membership.all.where(start_date: nil) + memberships_start_date_nil = Membership.where(start_date: nil) team_members_start_date_nil = memberships_start_date_nil.where(start_date: nil).map(&:team_member) memberships_start_date_nil.map(&:destroy) @@ -28,7 +28,7 @@ def down add_column :team_members, :hours_per_month, :integer - Membership.all.each { |membership| membership.team_member.update(hours_per_month: membership.hours_per_month) } + Membership.find_each { |membership| membership.team_member.update(hours_per_month: membership.hours_per_month) } change_table :memberships, bulk: true do |t| t.remove :hours_per_month diff --git a/db/migrate/20200130181814_add_role_to_user_and_company.rb b/db/migrate/20200130181814_add_role_to_user_and_company.rb index 6ced12231..43554c323 100644 --- a/db/migrate/20200130181814_add_role_to_user_and_company.rb +++ b/db/migrate/20200130181814_add_role_to_user_and_company.rb @@ -5,7 +5,6 @@ def change rename_table :companies_users, :user_company_roles change_table :user_company_roles, bulk: true do |t| - t.integer :id, index: true, primary_key: true t.integer :user_role, index: true, default: 0, null: false t.date :start_date diff --git a/db/migrate/20200430140032_add_customer_to_demand.rb b/db/migrate/20200430140032_add_customer_to_demand.rb index fbd255c7d..34bc95ea3 100644 --- a/db/migrate/20200430140032_add_customer_to_demand.rb +++ b/db/migrate/20200430140032_add_customer_to_demand.rb @@ -7,7 +7,7 @@ def change add_foreign_key :demands, :customers, columm: :customer_id - Customer.all.each do |customer| + Customer.find_each do |customer| customer.exclusive_projects.each do |project| project.demands.each do |demand| demand.update(customer: project.customers.first) diff --git a/db/migrate/20200615173415_add_item_assignment_effort.rb b/db/migrate/20200615173415_add_item_assignment_effort.rb index ad2eed100..18bbf8a2a 100644 --- a/db/migrate/20200615173415_add_item_assignment_effort.rb +++ b/db/migrate/20200615173415_add_item_assignment_effort.rb @@ -9,7 +9,7 @@ def up end add_foreign_key :item_assignments, :memberships, column: :membership_id - ItemAssignment.all.each do |item_assignment| + ItemAssignment.find_each do |item_assignment| membership = Membership.where(team_member_id: item_assignment.team_member_id, team: item_assignment.demand.team).first_or_initialize membership.update(start_date: Time.zone.today) unless membership.valid? diff --git a/db/migrate/20211110122935_rename_flow_impact_to_flow_event.rb b/db/migrate/20211110122935_rename_flow_impact_to_flow_event.rb index 6905615d2..cc4eddd54 100644 --- a/db/migrate/20211110122935_rename_flow_impact_to_flow_event.rb +++ b/db/migrate/20211110122935_rename_flow_impact_to_flow_event.rb @@ -20,7 +20,7 @@ def change change_column_null :flow_events, :project_id, true - FlowEvent.all.each { |event| event.update(company_id: event.project.company.id) } + FlowEvent.find_each { |event| event.update(company_id: event.project.company.id) } change_column_null :flow_events, :company_id, false end diff --git a/db/migrate/20220113202204_remove_customer_in_product_not_null.rb b/db/migrate/20220113202204_remove_customer_in_product_not_null.rb index c54602ef6..769ed8bfc 100644 --- a/db/migrate/20220113202204_remove_customer_in_product_not_null.rb +++ b/db/migrate/20220113202204_remove_customer_in_product_not_null.rb @@ -7,7 +7,7 @@ def change add_column :products, :company_id, :integer add_index :products, :company_id - Product.all.each do |product| + Product.find_each do |product| company_id = Customer.find_by(id: product.customer_id).company_id product.update(company_id: company_id) end diff --git a/db/migrate/20221205155616_add_slug_to_product.rb b/db/migrate/20221205155616_add_slug_to_product.rb index a69d50d53..8c5fbd56a 100644 --- a/db/migrate/20221205155616_add_slug_to_product.rb +++ b/db/migrate/20221205155616_add_slug_to_product.rb @@ -4,7 +4,7 @@ class AddSlugToProduct < ActiveRecord::Migration[7.0] def change add_column :products, :slug, :string - Product.all.each { |p| p.update(slug: p.name.parameterize) } + Product.find_each { |p| p.update(slug: p.name.parameterize) } change_column_null :products, :slug, false add_index :products, %i[company_id slug], unique: true diff --git a/db/passo 1 completo.rb b/db/passo 1 completo.rb deleted file mode 100644 index d370fcc25..000000000 --- a/db/passo 1 completo.rb +++ /dev/null @@ -1,1294 +0,0 @@ -# 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. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.0].define(version: 20_220_214_141_346) do - # These are extensions that must be enabled in order to support this database - enable_extension 'plpgsql' - - create_table 'azure_accounts', force: :cascade do |t| - t.bigint 'company_id', null: false - t.string 'username', null: false - t.string 'encrypted_password', null: false - t.string 'azure_organization', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'azure_work_item_query' - t.index ['company_id'], name: 'index_azure_accounts_on_company_id' - end - - create_table 'azure_custom_fields', force: :cascade do |t| - t.integer 'azure_account_id', null: false - t.integer 'custom_field_type', default: 0, null: false - t.string 'custom_field_name', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - end - - create_table 'azure_product_configs', force: :cascade do |t| - t.bigint 'product_id', null: false - t.bigint 'azure_account_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['azure_account_id'], name: 'index_azure_product_configs_on_azure_account_id' - t.index ['product_id'], name: 'index_azure_product_configs_on_product_id' - end - - create_table 'azure_projects', force: :cascade do |t| - t.integer 'azure_team_id', null: false - t.string 'project_id', null: false - t.string 'project_name', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['azure_team_id'], name: 'index_azure_projects_on_azure_team_id' - end - - create_table 'azure_teams', force: :cascade do |t| - t.integer 'azure_product_config_id', null: false - t.string 'team_id', null: false - t.string 'team_name', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['azure_product_config_id'], name: 'index_azure_teams_on_azure_product_config_id' - end - - create_table 'class_of_service_change_histories', force: :cascade do |t| - t.integer 'demand_id', null: false - t.datetime 'change_date', precision: nil, null: false - t.integer 'from_class_of_service' - t.integer 'to_class_of_service', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index %w[demand_id change_date], name: 'cos_history_unique', unique: true - t.index ['demand_id'], name: 'index_class_of_service_change_histories_on_demand_id' - end - - create_table 'companies', force: :cascade do |t| - t.string 'name', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'abbreviation', null: false - t.integer 'customers_count', default: 0 - t.string 'slug' - t.string 'api_token', null: false - t.index ['abbreviation'], name: 'index_companies_on_abbreviation', unique: true - t.index ['api_token'], name: 'index_companies_on_api_token', unique: true - t.index ['slug'], name: 'index_companies_on_slug', unique: true - end - - create_table 'company_settings', force: :cascade do |t| - t.integer 'company_id', null: false - t.integer 'max_active_parallel_projects', null: false - t.decimal 'max_flow_pressure', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['company_id'], name: 'index_company_settings_on_company_id' - end - - create_table 'contract_consolidations', force: :cascade do |t| - t.integer 'contract_id', null: false - t.date 'consolidation_date', null: false - t.decimal 'operational_risk_value', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.integer 'min_monte_carlo_weeks', default: 0 - t.integer 'max_monte_carlo_weeks', default: 0 - t.integer 'monte_carlo_duration_p80_weeks', default: 0 - t.integer 'estimated_hours_per_demand' - t.integer 'real_hours_per_demand' - t.decimal 'development_consumed_hours', default: '0.0', null: false - t.decimal 'design_consumed_hours', default: '0.0', null: false - t.decimal 'management_consumed_hours', default: '0.0', null: false - t.decimal 'development_consumed_hours_in_month', default: '0.0', null: false - t.decimal 'design_consumed_hours_in_month', default: '0.0', null: false - t.decimal 'management_consumed_hours_in_month', default: '0.0', null: false - t.index ['consolidation_date'], name: 'index_contract_consolidations_on_consolidation_date' - t.index %w[contract_id consolidation_date], name: 'idx_contract_consolidation_unique', unique: true - t.index ['contract_id'], name: 'index_contract_consolidations_on_contract_id' - end - - create_table 'contract_estimation_change_histories', force: :cascade do |t| - t.integer 'contract_id', null: false - t.datetime 'change_date', precision: nil, null: false - t.integer 'hours_per_demand', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - end - - create_table 'contracts', force: :cascade do |t| - t.integer 'product_id', null: false - t.integer 'customer_id', null: false - t.integer 'contract_id' - t.date 'start_date', null: false - t.date 'end_date' - t.integer 'renewal_period', default: 0, null: false - t.boolean 'automatic_renewal', default: false - t.integer 'total_hours', null: false - t.integer 'total_value', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.integer 'hours_per_demand', default: 1, null: false - t.index ['contract_id'], name: 'index_contracts_on_contract_id' - t.index ['customer_id'], name: 'index_contracts_on_customer_id' - t.index ['product_id'], name: 'index_contracts_on_product_id' - end - - create_table 'customer_consolidations', force: :cascade do |t| - t.integer 'customer_id', null: false - t.date 'consolidation_date', null: false - t.boolean 'last_data_in_week', default: false - t.boolean 'last_data_in_month', default: false - t.boolean 'last_data_in_year', default: false - t.decimal 'consumed_hours', default: '0.0' - t.decimal 'consumed_hours_in_month', default: '0.0' - t.decimal 'average_consumed_hours_in_month', default: '0.0' - t.decimal 'flow_pressure', default: '0.0' - t.decimal 'lead_time_p80', default: '0.0' - t.decimal 'lead_time_p80_in_month', default: '0.0' - t.decimal 'value_per_demand', default: '0.0' - t.decimal 'value_per_demand_in_month', default: '0.0' - t.decimal 'hours_per_demand', default: '0.0' - t.decimal 'hours_per_demand_in_month', default: '0.0' - t.integer 'qty_demands_created', default: 0 - t.integer 'qty_demands_committed', default: 0 - t.integer 'qty_demands_finished', default: 0 - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.decimal 'development_consumed_hours', default: '0.0', null: false - t.decimal 'design_consumed_hours', default: '0.0', null: false - t.decimal 'management_consumed_hours', default: '0.0', null: false - t.decimal 'development_consumed_hours_in_month', default: '0.0', null: false - t.decimal 'design_consumed_hours_in_month', default: '0.0', null: false - t.decimal 'management_consumed_hours_in_month', default: '0.0', null: false - t.index %w[customer_id consolidation_date], name: 'customer_consolidation_unique', unique: true - t.index ['customer_id'], name: 'index_customer_consolidations_on_customer_id' - t.index ['last_data_in_month'], name: 'index_customer_consolidations_on_last_data_in_month' - t.index ['last_data_in_week'], name: 'index_customer_consolidations_on_last_data_in_week' - t.index ['last_data_in_year'], name: 'index_customer_consolidations_on_last_data_in_year' - end - - create_table 'customers', force: :cascade do |t| - t.integer 'company_id', null: false - t.string 'name', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'products_count', default: 0 - t.integer 'projects_count', default: 0 - t.integer 'customer_id' - t.index %w[company_id name], name: 'index_customers_on_company_id_and_name', unique: true - t.index ['company_id'], name: 'index_customers_on_company_id' - t.index ['customer_id'], name: 'index_customers_on_customer_id' - end - - create_table 'customers_devise_customers', force: :cascade do |t| - t.integer 'customer_id', null: false - t.integer 'devise_customer_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index %w[customer_id devise_customer_id], name: 'idx_customers_devise_customer_unique', unique: true - t.index ['customer_id'], name: 'index_customers_devise_customers_on_customer_id' - t.index ['devise_customer_id'], name: 'index_customers_devise_customers_on_devise_customer_id' - end - - create_table 'customers_projects', force: :cascade do |t| - t.integer 'customer_id', null: false - t.integer 'project_id', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index %w[customer_id project_id], name: 'index_customers_projects_on_customer_id_and_project_id', unique: true - t.index ['customer_id'], name: 'index_customers_projects_on_customer_id' - t.index ['project_id'], name: 'index_customers_projects_on_project_id' - end - - create_table 'demand_block_notifications', force: :cascade do |t| - t.integer 'demand_block_id', null: false - t.integer 'block_state', default: 0, null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['block_state'], name: 'index_demand_block_notifications_on_block_state' - t.index ['demand_block_id'], name: 'index_demand_block_notifications_on_demand_block_id' - end - - create_table 'demand_blocks', force: :cascade do |t| - t.integer 'demand_id', null: false - t.datetime 'block_time', precision: nil, null: false - t.datetime 'unblock_time', precision: nil - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.boolean 'active', default: true, null: false - t.integer 'block_type', default: 0, null: false - t.datetime 'discarded_at', precision: nil - t.integer 'stage_id' - t.string 'block_reason' - t.integer 'blocker_id', null: false - t.integer 'unblocker_id' - t.string 'unblock_reason' - t.integer 'risk_review_id' - t.decimal 'block_working_time_duration' - t.integer 'lock_version' - t.index ['blocker_id'], name: 'index_demand_blocks_on_blocker_id' - t.index ['demand_id'], name: 'index_demand_blocks_on_demand_id' - t.index ['discarded_at'], name: 'index_demand_blocks_on_discarded_at' - t.index ['risk_review_id'], name: 'index_demand_blocks_on_risk_review_id' - t.index ['stage_id'], name: 'index_demand_blocks_on_stage_id' - t.index ['unblocker_id'], name: 'index_demand_blocks_on_unblocker_id' - end - - create_table 'demand_comments', force: :cascade do |t| - t.integer 'demand_id', null: false - t.datetime 'comment_date', precision: nil, null: false - t.string 'comment_text', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'team_member_id' - t.datetime 'discarded_at', precision: nil - t.index ['demand_id'], name: 'index_demand_comments_on_demand_id' - t.index ['discarded_at'], name: 'index_demand_comments_on_discarded_at' - t.index ['team_member_id'], name: 'index_demand_comments_on_team_member_id' - end - - create_table 'demand_efforts', force: :cascade do |t| - t.integer 'item_assignment_id', null: false - t.integer 'demand_transition_id', null: false - t.integer 'demand_id', null: false - t.boolean 'main_effort_in_transition', default: false, null: false - t.boolean 'automatic_update', default: true, null: false - t.datetime 'start_time_to_computation', precision: nil, null: false - t.datetime 'finish_time_to_computation', precision: nil, null: false - t.decimal 'effort_value', default: '0.0', null: false - t.decimal 'management_percentage', default: '0.0', null: false - t.decimal 'pairing_percentage', default: '0.0', null: false - t.decimal 'stage_percentage', default: '0.0', null: false - t.decimal 'total_blocked', default: '0.0', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.decimal 'effort_with_blocks', default: '0.0' - t.integer 'lock_version' - t.index ['demand_id'], name: 'index_demand_efforts_on_demand_id' - t.index ['demand_transition_id'], name: 'index_demand_efforts_on_demand_transition_id' - t.index %w[item_assignment_id demand_transition_id start_time_to_computation], name: 'idx_demand_efforts_unique', unique: true - t.index ['item_assignment_id'], name: 'index_demand_efforts_on_item_assignment_id' - end - - create_table 'demand_score_matrices', force: :cascade do |t| - t.integer 'demand_id', null: false - t.integer 'user_id', null: false - t.integer 'score_matrix_answer_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['demand_id'], name: 'index_demand_score_matrices_on_demand_id' - t.index ['score_matrix_answer_id'], name: 'index_demand_score_matrices_on_score_matrix_answer_id' - t.index ['user_id'], name: 'index_demand_score_matrices_on_user_id' - end - - create_table 'demand_transitions', force: :cascade do |t| - t.integer 'demand_id', null: false - t.integer 'stage_id', null: false - t.datetime 'last_time_in', precision: nil, null: false - t.datetime 'last_time_out', precision: nil - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.datetime 'discarded_at', precision: nil - t.boolean 'transition_notified', default: false, null: false - t.integer 'team_member_id' - t.integer 'lock_version' - t.index %w[demand_id stage_id last_time_in], name: 'idx_transitions_unique', unique: true - t.index ['demand_id'], name: 'index_demand_transitions_on_demand_id' - t.index ['discarded_at'], name: 'index_demand_transitions_on_discarded_at' - t.index ['stage_id'], name: 'index_demand_transitions_on_stage_id' - t.index ['team_member_id'], name: 'index_demand_transitions_on_team_member_id' - t.index ['transition_notified'], name: 'index_demand_transitions_on_transition_notified' - end - - create_table 'demands', force: :cascade do |t| - t.string 'external_id', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'demand_type', null: false - t.string 'demand_url' - t.datetime 'commitment_date', precision: nil - t.datetime 'end_date', precision: nil - t.datetime 'created_date', precision: nil, null: false - t.string 'external_url' - t.integer 'class_of_service', default: 0, null: false - t.integer 'project_id' - t.decimal 'effort_downstream', default: '0.0' - t.decimal 'effort_upstream', default: '0.0' - t.decimal 'leadtime' - t.boolean 'manual_effort', default: false - t.integer 'total_queue_time', default: 0 - t.integer 'total_touch_time', default: 0 - t.string 'demand_title' - t.datetime 'discarded_at', precision: nil - t.string 'slug' - t.integer 'company_id', null: false - t.integer 'portfolio_unit_id' - t.integer 'product_id' - t.integer 'team_id', null: false - t.decimal 'cost_to_project', default: '0.0' - t.decimal 'total_bloked_working_time', default: '0.0' - t.decimal 'total_touch_blocked_time', default: '0.0' - t.integer 'risk_review_id' - t.decimal 'demand_score', default: '0.0' - t.integer 'service_delivery_review_id' - t.integer 'current_stage_id' - t.integer 'customer_id' - t.string 'demand_tags', default: [], array: true - t.integer 'contract_id' - t.decimal 'effort_development', default: '0.0', null: false - t.decimal 'effort_design', default: '0.0', null: false - t.decimal 'effort_management', default: '0.0', null: false - t.index ['class_of_service'], name: 'index_demands_on_class_of_service' - t.index ['company_id'], name: 'index_demands_on_company_id' - t.index ['contract_id'], name: 'index_demands_on_contract_id' - t.index ['current_stage_id'], name: 'index_demands_on_current_stage_id' - t.index ['customer_id'], name: 'index_demands_on_customer_id' - t.index ['demand_type'], name: 'index_demands_on_demand_type' - t.index ['discarded_at'], name: 'index_demands_on_discarded_at' - t.index %w[external_id company_id], name: 'index_demands_on_external_id_and_company_id', unique: true - t.index ['portfolio_unit_id'], name: 'index_demands_on_portfolio_unit_id' - t.index ['product_id'], name: 'index_demands_on_product_id' - t.index ['project_id'], name: 'index_demands_on_project_id' - t.index ['risk_review_id'], name: 'index_demands_on_risk_review_id' - t.index ['service_delivery_review_id'], name: 'index_demands_on_service_delivery_review_id' - t.index ['slug'], name: 'index_demands_on_slug', unique: true - t.index ['team_id'], name: 'index_demands_on_team_id' - end - - create_table 'dashboard', force: :cascade do |t| - t.string 'first_name', null: false - t.string 'last_name', null: false - t.string 'email', default: '', null: false - t.string 'encrypted_password', default: '', null: false - t.string 'reset_password_token' - t.datetime 'reset_password_sent_at', precision: nil - t.datetime 'remember_created_at', precision: nil - t.integer 'sign_in_count', default: 0, null: false - t.datetime 'current_sign_in_at', precision: nil - t.datetime 'last_sign_in_at', precision: nil - t.inet 'current_sign_in_ip' - t.inet 'last_sign_in_ip' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['email'], name: 'index_devise_customers_on_email', unique: true - t.index ['reset_password_token'], name: 'index_devise_customers_on_reset_password_token', unique: true - end - - create_table 'financial_informations', force: :cascade do |t| - t.integer 'company_id', null: false - t.date 'finances_date', null: false - t.decimal 'income_total', null: false - t.decimal 'expenses_total', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['company_id'], name: 'index_financial_informations_on_company_id' - end - - create_table 'flow_events', force: :cascade do |t| - t.integer 'project_id' - t.integer 'event_type', null: false - t.string 'event_description', null: false - t.datetime 'event_date', precision: nil, null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'risk_review_id' - t.datetime 'discarded_at', precision: nil - t.integer 'event_size', default: 0, null: false - t.integer 'user_id' - t.date 'event_end_date' - t.integer 'company_id', null: false - t.integer 'team_id' - t.index ['discarded_at'], name: 'index_flow_events_on_discarded_at' - t.index ['event_size'], name: 'index_flow_events_on_event_size' - t.index ['event_type'], name: 'index_flow_events_on_event_type' - t.index ['project_id'], name: 'index_flow_events_on_project_id' - t.index ['risk_review_id'], name: 'index_flow_events_on_risk_review_id' - t.index ['user_id'], name: 'index_flow_events_on_user_id' - end - - create_table 'friendly_id_slugs', force: :cascade do |t| - t.string 'slug', null: false - t.integer 'sluggable_id', null: false - t.string 'sluggable_type', limit: 50 - t.string 'scope' - t.datetime 'created_at' - t.index %w[slug sluggable_type scope], name: 'index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope', unique: true - t.index %w[slug sluggable_type], name: 'index_friendly_id_slugs_on_slug_and_sluggable_type' - t.index %w[sluggable_type sluggable_id], name: 'index_friendly_id_slugs_on_sluggable_type_and_sluggable_id' - end - - create_table 'initiative_consolidations', force: :cascade do |t| - t.integer 'initiative_id', null: false - t.date 'consolidation_date', null: false - t.boolean 'last_data_in_week', default: false - t.boolean 'last_data_in_month', default: false - t.boolean 'last_data_in_year', default: false - t.integer 'tasks_delivered' - t.integer 'tasks_delivered_in_month' - t.integer 'tasks_delivered_in_week' - t.decimal 'tasks_operational_risk' - t.integer 'tasks_scope' - t.decimal 'tasks_completion_time_p80' - t.decimal 'tasks_completion_time_p80_in_month' - t.decimal 'tasks_completion_time_p80_in_week' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['consolidation_date'], name: 'index_initiative_consolidations_on_consolidation_date' - t.index %w[initiative_id consolidation_date], name: 'initiative_consolidation_unique', unique: true - t.index ['initiative_id'], name: 'index_initiative_consolidations_on_initiative_id' - end - - create_table 'initiatives', force: :cascade do |t| - t.integer 'company_id', null: false - t.string 'name', null: false - t.date 'start_date', null: false - t.date 'end_date', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index %w[company_id name], name: 'index_initiatives_on_company_id_and_name', unique: true - t.index ['company_id'], name: 'index_initiatives_on_company_id' - t.index ['name'], name: 'index_initiatives_on_name' - end - - create_table 'integration_errors', force: :cascade do |t| - t.integer 'company_id', null: false - t.datetime 'occured_at', precision: nil, default: -> { 'CURRENT_TIMESTAMP' }, null: false - t.integer 'integration_type', null: false - t.string 'integration_error_text', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'project_id' - t.string 'integratable_model_name' - t.index ['company_id'], name: 'index_integration_errors_on_company_id' - t.index ['integratable_model_name'], name: 'index_integration_errors_on_integratable_model_name' - t.index ['integration_type'], name: 'index_integration_errors_on_integration_type' - t.index ['project_id'], name: 'index_integration_errors_on_project_id' - end - - create_table 'item_assignments', force: :cascade do |t| - t.integer 'demand_id', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.datetime 'start_time', precision: nil, null: false - t.datetime 'finish_time', precision: nil - t.datetime 'discarded_at', precision: nil - t.decimal 'item_assignment_effort', default: '0.0', null: false - t.boolean 'assignment_for_role', default: false - t.integer 'membership_id', null: false - t.decimal 'pull_interval', default: '0.0' - t.boolean 'assignment_notified', default: false, null: false - t.integer 'lock_version' - t.index ['demand_id'], name: 'index_item_assignments_on_demand_id' - t.index ['discarded_at'], name: 'index_item_assignments_on_discarded_at' - t.index ['membership_id'], name: 'index_item_assignments_on_membership_id' - end - - create_table 'jira_accounts', force: :cascade do |t| - t.integer 'company_id', null: false - t.string 'username', null: false - t.string 'encrypted_api_token', null: false - t.string 'base_uri', null: false - t.string 'customer_domain', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['base_uri'], name: 'index_jira_accounts_on_base_uri', unique: true - t.index ['company_id'], name: 'index_jira_accounts_on_company_id' - t.index ['customer_domain'], name: 'index_jira_accounts_on_customer_domain', unique: true - end - - create_table 'jira_api_errors', force: :cascade do |t| - t.integer 'demand_id', null: false - t.boolean 'processed', default: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['demand_id'], name: 'index_jira_api_errors_on_demand_id' - end - - create_table 'jira_custom_field_mappings', force: :cascade do |t| - t.integer 'jira_account_id', null: false - t.integer 'custom_field_type', null: false - t.string 'custom_field_machine_name', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index %w[jira_account_id custom_field_type], name: 'unique_custom_field_to_jira_account', unique: true - t.index ['jira_account_id'], name: 'index_jira_custom_field_mappings_on_jira_account_id' - end - - create_table 'jira_portfolio_unit_configs', force: :cascade do |t| - t.integer 'portfolio_unit_id', null: false - t.string 'jira_field_name', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['portfolio_unit_id'], name: 'index_jira_portfolio_unit_configs_on_portfolio_unit_id' - end - - create_table 'jira_product_configs', force: :cascade do |t| - t.integer 'company_id', null: false - t.integer 'product_id', null: false - t.string 'jira_product_key', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index %w[company_id jira_product_key], name: 'index_jira_product_configs_on_company_id_and_jira_product_key', unique: true - t.index ['company_id'], name: 'index_jira_product_configs_on_company_id' - t.index ['product_id'], name: 'index_jira_product_configs_on_product_id' - end - - create_table 'jira_project_configs', force: :cascade do |t| - t.integer 'project_id', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.string 'fix_version_name', null: false - t.integer 'jira_product_config_id', null: false - t.index ['fix_version_name'], name: 'index_jira_project_configs_on_fix_version_name' - t.index %w[jira_product_config_id fix_version_name], name: 'unique_fix_version_to_jira_product', unique: true - t.index ['jira_product_config_id'], name: 'index_jira_project_configs_on_jira_product_config_id' - t.index ['project_id'], name: 'index_jira_project_configs_on_project_id' - end - - create_table 'memberships', force: :cascade do |t| - t.integer 'team_member_id', null: false - t.integer 'team_id', null: false - t.integer 'member_role', default: 0, null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'hours_per_month' - t.date 'start_date', null: false - t.date 'end_date' - t.index ['team_id'], name: 'index_memberships_on_team_id' - t.index ['team_member_id'], name: 'index_memberships_on_team_member_id' - end - - create_table 'operations_dashboard_pairings', force: :cascade do |t| - t.integer 'operations_dashboard_id', null: false - t.integer 'pair_id', null: false - t.integer 'pair_times', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index %w[operations_dashboard_id pair_id], name: 'operations_dashboard_pairings_cache_unique', unique: true - t.index ['operations_dashboard_id'], name: 'index_operations_dashboard_pairings_on_operations_dashboard_id' - t.index ['pair_id'], name: 'index_operations_dashboard_pairings_on_pair_id' - end - - create_table 'operations_dashboards', force: :cascade do |t| - t.date 'dashboard_date', null: false - t.boolean 'last_data_in_week', default: false, null: false - t.boolean 'last_data_in_month', default: false, null: false - t.boolean 'last_data_in_year', default: false, null: false - t.integer 'team_member_id', null: false - t.integer 'demands_ids', array: true - t.integer 'first_delivery_id' - t.integer 'delivered_demands_count', default: 0, null: false - t.integer 'bugs_count', default: 0, null: false - t.decimal 'lead_time_min', default: '0.0', null: false - t.decimal 'lead_time_max', default: '0.0', null: false - t.decimal 'lead_time_p80', default: '0.0', null: false - t.integer 'projects_count', default: 0, null: false - t.decimal 'member_effort' - t.integer 'pull_interval' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index %w[team_member_id dashboard_date], name: 'operations_dashboard_cache_unique', unique: true - t.index ['team_member_id'], name: 'index_operations_dashboards_on_team_member_id' - end - - create_table 'plans', force: :cascade do |t| - t.integer 'plan_value', null: false - t.integer 'plan_type', null: false - t.integer 'plan_period', null: false - t.string 'plan_details', null: false - t.integer 'max_number_of_downloads', null: false - t.integer 'max_number_of_users', null: false - t.integer 'max_days_in_history', null: false - t.decimal 'extra_download_value', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - end - - create_table 'portfolio_units', force: :cascade do |t| - t.integer 'product_id', null: false - t.integer 'parent_id' - t.string 'name', null: false - t.integer 'portfolio_unit_type', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index %w[name product_id], name: 'index_portfolio_units_on_name_and_product_id', unique: true - t.index ['name'], name: 'index_portfolio_units_on_name' - t.index ['parent_id'], name: 'index_portfolio_units_on_parent_id' - t.index ['portfolio_unit_type'], name: 'index_portfolio_units_on_portfolio_unit_type' - t.index ['product_id'], name: 'index_portfolio_units_on_product_id' - end - - create_table 'products', force: :cascade do |t| - t.integer 'customer_id' - t.string 'name', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'company_id', null: false - t.index ['company_id'], name: 'index_products_on_company_id' - t.index %w[customer_id name], name: 'index_products_on_customer_id_and_name', unique: true - t.index ['customer_id'], name: 'index_products_on_customer_id' - end - - create_table 'products_projects', force: :cascade do |t| - t.integer 'product_id', null: false - t.integer 'project_id', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index %w[product_id project_id], name: 'index_products_projects_on_product_id_and_project_id', unique: true - t.index ['product_id'], name: 'index_products_projects_on_product_id' - t.index ['project_id'], name: 'index_products_projects_on_project_id' - end - - create_table 'project_broken_wip_logs', force: :cascade do |t| - t.integer 'project_id', null: false - t.integer 'project_wip', null: false - t.integer 'demands_ids', null: false, array: true - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['project_id'], name: 'index_project_broken_wip_logs_on_project_id' - end - - create_table 'project_change_deadline_histories', force: :cascade do |t| - t.integer 'project_id', null: false - t.integer 'user_id', null: false - t.date 'previous_date' - t.date 'new_date' - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['project_id'], name: 'index_project_change_deadline_histories_on_project_id' - t.index ['user_id'], name: 'index_project_change_deadline_histories_on_user_id' - end - - create_table 'project_consolidations', force: :cascade do |t| - t.date 'consolidation_date', null: false - t.integer 'project_id', null: false - t.integer 'demands_ids', array: true - t.integer 'demands_finished_ids', array: true - t.integer 'wip_limit' - t.integer 'current_wip' - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.boolean 'last_data_in_week', default: false, null: false - t.boolean 'last_data_in_month', default: false, null: false - t.boolean 'last_data_in_year', default: false, null: false - t.integer 'project_scope', default: 0 - t.decimal 'flow_pressure', default: '0.0' - t.decimal 'project_quality', default: '0.0' - t.decimal 'value_per_demand', default: '0.0' - t.integer 'monte_carlo_weeks_min', default: 0 - t.integer 'monte_carlo_weeks_max', default: 0 - t.decimal 'monte_carlo_weeks_std_dev', default: '0.0' - t.decimal 'monte_carlo_weeks_p80', default: '0.0' - t.decimal 'operational_risk', default: '0.0' - t.integer 'team_based_monte_carlo_weeks_min', default: 0 - t.integer 'team_based_monte_carlo_weeks_max', default: 0 - t.decimal 'team_based_monte_carlo_weeks_std_dev', default: '0.0' - t.decimal 'team_based_monte_carlo_weeks_p80', default: '0.0' - t.decimal 'team_based_operational_risk', default: '0.0' - t.decimal 'lead_time_min', default: '0.0' - t.decimal 'lead_time_max', default: '0.0' - t.decimal 'lead_time_p25', default: '0.0' - t.decimal 'lead_time_p75', default: '0.0' - t.decimal 'lead_time_p80', default: '0.0' - t.decimal 'lead_time_average', default: '0.0' - t.decimal 'lead_time_std_dev', default: '0.0' - t.decimal 'lead_time_histogram_bin_min', default: '0.0' - t.decimal 'lead_time_histogram_bin_max', default: '0.0' - t.decimal 'weeks_by_little_law', default: '0.0' - t.integer 'project_throughput', default: 0 - t.decimal 'hours_per_demand', default: '0.0' - t.decimal 'flow_efficiency', default: '0.0' - t.integer 'bugs_opened', default: 0 - t.integer 'bugs_closed', default: 0 - t.decimal 'lead_time_p65', default: '0.0' - t.decimal 'lead_time_p95', default: '0.0' - t.decimal 'lead_time_min_month', default: '0.0' - t.decimal 'lead_time_max_month', default: '0.0' - t.decimal 'lead_time_p80_month', default: '0.0' - t.decimal 'lead_time_std_dev_month', default: '0.0' - t.decimal 'flow_efficiency_month', default: '0.0' - t.decimal 'hours_per_demand_month', default: '0.0' - t.integer 'code_needed_blocks_count', default: 0 - t.decimal 'code_needed_blocks_per_demand', default: '0.0' - t.integer 'project_scope_hours', default: 0 - t.decimal 'project_throughput_hours', default: '0.0' - t.decimal 'project_throughput_hours_upstream', default: '0.0' - t.decimal 'project_throughput_hours_downstream', default: '0.0' - t.decimal 'project_throughput_hours_in_month' - t.decimal 'project_throughput_hours_upstream_in_month' - t.decimal 'project_throughput_hours_downstream_in_month' - t.decimal 'project_throughput_hours_development', default: '0.0', null: false - t.decimal 'project_throughput_hours_design', default: '0.0', null: false - t.decimal 'project_throughput_hours_management', default: '0.0', null: false - t.decimal 'project_throughput_hours_development_in_month', default: '0.0', null: false - t.decimal 'project_throughput_hours_design_in_month', default: '0.0', null: false - t.decimal 'project_throughput_hours_management_in_month', default: '0.0', null: false - t.decimal 'tasks_based_operational_risk', default: '0.0' - t.decimal 'tasks_based_deadline_p80', default: '0.0' - end - - create_table 'project_risk_alerts', force: :cascade do |t| - t.integer 'project_id', null: false - t.integer 'project_risk_config_id', null: false - t.integer 'alert_color', null: false - t.decimal 'alert_value', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['project_id'], name: 'index_project_risk_alerts_on_project_id' - t.index ['project_risk_config_id'], name: 'index_project_risk_alerts_on_project_risk_config_id' - end - - create_table 'project_risk_configs', force: :cascade do |t| - t.integer 'risk_type', null: false - t.decimal 'high_yellow_value', null: false - t.decimal 'low_yellow_value', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'project_id', null: false - t.boolean 'active', default: true - t.index ['project_id'], name: 'index_project_risk_configs_on_project_id' - end - - create_table 'projects', force: :cascade do |t| - t.string 'name', null: false - t.integer 'status', null: false - t.integer 'project_type', null: false - t.date 'start_date', null: false - t.date 'end_date', null: false - t.decimal 'value' - t.decimal 'qty_hours' - t.decimal 'hour_value' - t.integer 'initial_scope', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.string 'nickname' - t.integer 'percentage_effort_to_bugs', default: 0, null: false - t.integer 'team_id', null: false - t.decimal 'max_work_in_progress', default: '1.0', null: false - t.integer 'company_id', null: false - t.integer 'initiative_id' - t.index %w[company_id name], name: 'index_projects_on_company_id_and_name', unique: true - t.index ['company_id'], name: 'index_projects_on_company_id' - t.index ['team_id'], name: 'index_projects_on_team_id' - end - - create_table 'replenishing_consolidations', force: :cascade do |t| - t.integer 'project_id', null: false - t.date 'consolidation_date', null: false - t.decimal 'project_based_risks_to_deadline' - t.decimal 'flow_pressure' - t.decimal 'relative_flow_pressure' - t.decimal 'qty_using_pressure' - t.decimal 'leadtime_80' - t.decimal 'qty_selected_last_week' - t.decimal 'work_in_progress' - t.decimal 'montecarlo_80_percent' - t.decimal 'customer_happiness' - t.integer 'max_work_in_progress' - t.integer 'project_throughput_data', array: true - t.integer 'team_wip' - t.integer 'team_throughput_data', array: true - t.decimal 'team_lead_time' - t.decimal 'team_based_montecarlo_80_percent' - t.decimal 'team_monte_carlo_weeks_std_dev' - t.decimal 'team_monte_carlo_weeks_min' - t.decimal 'team_monte_carlo_weeks_max' - t.decimal 'team_based_odds_to_deadline' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['consolidation_date'], name: 'index_replenishing_consolidations_on_consolidation_date' - t.index %w[project_id consolidation_date], name: 'idx_replenishing_unique', unique: true - t.index ['project_id'], name: 'index_replenishing_consolidations_on_project_id' - end - - create_table 'risk_review_action_items', force: :cascade do |t| - t.integer 'risk_review_id', null: false - t.integer 'membership_id', null: false - t.date 'created_date', null: false - t.integer 'action_type', default: 0, null: false - t.string 'description', null: false - t.date 'deadline', null: false - t.date 'done_date' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['action_type'], name: 'index_risk_review_action_items_on_action_type' - t.index ['membership_id'], name: 'index_risk_review_action_items_on_membership_id' - t.index ['risk_review_id'], name: 'index_risk_review_action_items_on_risk_review_id' - end - - create_table 'risk_reviews', force: :cascade do |t| - t.integer 'company_id', null: false - t.integer 'product_id', null: false - t.date 'meeting_date', null: false - t.decimal 'lead_time_outlier_limit', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.decimal 'weekly_avg_blocked_time', array: true - t.decimal 'monthly_avg_blocked_time', array: true - t.index ['company_id'], name: 'index_risk_reviews_on_company_id' - t.index %w[meeting_date product_id], name: 'index_risk_reviews_on_meeting_date_and_product_id', unique: true - t.index ['product_id'], name: 'index_risk_reviews_on_product_id' - end - - create_table 'score_matrices', force: :cascade do |t| - t.integer 'product_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['product_id'], name: 'index_score_matrices_on_product_id' - end - - create_table 'score_matrix_answers', force: :cascade do |t| - t.integer 'score_matrix_question_id', null: false - t.string 'description', null: false - t.integer 'answer_value', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index %w[answer_value score_matrix_question_id], name: 'idx_demand_score_answers_unique', unique: true - t.index ['score_matrix_question_id'], name: 'index_score_matrix_answers_on_score_matrix_question_id' - end - - create_table 'score_matrix_questions', force: :cascade do |t| - t.integer 'score_matrix_id', null: false - t.integer 'question_type', default: 0, null: false - t.string 'description', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.integer 'question_weight', null: false - t.index ['score_matrix_id'], name: 'index_score_matrix_questions_on_score_matrix_id' - end - - create_table 'service_delivery_reviews', force: :cascade do |t| - t.integer 'company_id', null: false - t.integer 'product_id', null: false - t.date 'meeting_date', null: false - t.decimal 'lead_time_top_threshold', null: false - t.decimal 'lead_time_bottom_threshold', null: false - t.decimal 'quality_top_threshold', null: false - t.decimal 'quality_bottom_threshold', null: false - t.integer 'expedite_max_pull_time_sla', null: false - t.decimal 'delayed_expedite_top_threshold', null: false - t.decimal 'delayed_expedite_bottom_threshold', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.integer 'bugs_ids', array: true - t.index ['company_id'], name: 'index_service_delivery_reviews_on_company_id' - t.index %w[meeting_date product_id], name: 'index_service_delivery_reviews_on_meeting_date_and_product_id', unique: true - t.index ['product_id'], name: 'index_service_delivery_reviews_on_product_id' - end - - create_table 'sessions', force: :cascade do |t| - t.string 'session_id', null: false - t.text 'data' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['session_id'], name: 'index_sessions_on_session_id', unique: true - t.index ['updated_at'], name: 'index_sessions_on_updated_at' - end - - create_table 'slack_configurations', force: :cascade do |t| - t.integer 'team_id', null: false - t.string 'room_webhook', null: false - t.integer 'notification_hour' - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'info_type', default: 0, null: false - t.integer 'weekday_to_notify', default: 0, null: false - t.integer 'notification_minute' - t.boolean 'active', default: true - t.integer 'stages_to_notify_transition', array: true - t.index %w[info_type team_id], name: 'index_slack_configurations_on_info_type_and_team_id', unique: true - t.index ['info_type'], name: 'index_slack_configurations_on_info_type' - t.index ['team_id'], name: 'index_slack_configurations_on_team_id' - end - - create_table 'stage_project_configs', force: :cascade do |t| - t.integer 'project_id', null: false - t.integer 'stage_id', null: false - t.boolean 'compute_effort', default: false - t.integer 'stage_percentage', default: 0, null: false - t.integer 'management_percentage', default: 0, null: false - t.integer 'pairing_percentage', default: 0, null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'max_seconds_in_stage', default: 0 - t.index %w[project_id stage_id], name: 'index_stage_project_configs_on_project_id_and_stage_id', unique: true - t.index ['project_id'], name: 'index_stage_project_configs_on_project_id' - t.index ['stage_id'], name: 'index_stage_project_configs_on_stage_id' - end - - create_table 'stages', force: :cascade do |t| - t.string 'integration_id', null: false - t.string 'name', null: false - t.integer 'stage_type', default: 0, null: false - t.integer 'stage_stream', default: 0, null: false - t.boolean 'commitment_point', default: false - t.boolean 'end_point', default: false - t.boolean 'queue', default: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'company_id', null: false - t.integer 'order', default: 0, null: false - t.string 'integration_pipe_id' - t.index ['company_id'], name: 'index_stages_on_company_id' - t.index ['integration_id'], name: 'index_stages_on_integration_id' - t.index ['name'], name: 'index_stages_on_name' - end - - create_table 'stages_teams', force: :cascade do |t| - t.integer 'stage_id', null: false - t.integer 'team_id', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index %w[stage_id team_id], name: 'index_stages_teams_on_stage_id_and_team_id', unique: true - t.index ['stage_id'], name: 'index_stages_teams_on_stage_id' - t.index ['team_id'], name: 'index_stages_teams_on_team_id' - end - - create_table 'tasks', force: :cascade do |t| - t.integer 'demand_id', null: false - t.datetime 'created_date', precision: nil, null: false - t.string 'title', null: false - t.integer 'external_id' - t.integer 'seconds_to_complete' - t.datetime 'end_date', precision: nil - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.datetime 'discarded_at', precision: nil - t.index ['demand_id'], name: 'index_tasks_on_demand_id' - t.index ['discarded_at'], name: 'index_tasks_on_discarded_at' - end - - create_table 'team_consolidations', force: :cascade do |t| - t.integer 'team_id', null: false - t.date 'consolidation_date', null: false - t.boolean 'last_data_in_week', default: false - t.boolean 'last_data_in_month', default: false - t.boolean 'last_data_in_year', default: false - t.decimal 'consumed_hours_in_month', default: '0.0' - t.decimal 'lead_time_p80', default: '0.0' - t.decimal 'lead_time_p80_in_week', default: '0.0' - t.decimal 'lead_time_p80_in_month', default: '0.0' - t.decimal 'lead_time_p80_in_quarter', default: '0.0' - t.decimal 'lead_time_p80_in_semester', default: '0.0' - t.decimal 'lead_time_p80_in_year', default: '0.0' - t.decimal 'flow_efficiency', default: '0.0' - t.decimal 'flow_efficiency_in_month', default: '0.0' - t.decimal 'flow_efficiency_in_quarter', default: '0.0' - t.decimal 'flow_efficiency_in_semester', default: '0.0' - t.decimal 'flow_efficiency_in_year', default: '0.0' - t.decimal 'hours_per_demand', default: '0.0' - t.decimal 'hours_per_demand_in_month', default: '0.0' - t.decimal 'hours_per_demand_in_quarter', default: '0.0' - t.decimal 'hours_per_demand_in_semester', default: '0.0' - t.decimal 'hours_per_demand_in_year', default: '0.0' - t.decimal 'value_per_demand', default: '0.0' - t.decimal 'value_per_demand_in_month', default: '0.0' - t.decimal 'value_per_demand_in_quarter', default: '0.0' - t.decimal 'value_per_demand_in_semester', default: '0.0' - t.decimal 'value_per_demand_in_year', default: '0.0' - t.integer 'qty_demands_created', default: 0 - t.integer 'qty_demands_created_in_week', default: 0 - t.integer 'qty_demands_committed', default: 0 - t.integer 'qty_demands_committed_in_week', default: 0 - t.integer 'qty_demands_finished_upstream', default: 0 - t.integer 'qty_demands_finished_upstream_in_week', default: 0 - t.integer 'qty_demands_finished_upstream_in_month', default: 0 - t.integer 'qty_demands_finished_upstream_in_quarter', default: 0 - t.integer 'qty_demands_finished_upstream_in_semester', default: 0 - t.integer 'qty_demands_finished_upstream_in_year', default: 0 - t.integer 'qty_demands_finished_downstream', default: 0 - t.integer 'qty_demands_finished_downstream_in_week', default: 0 - t.integer 'qty_demands_finished_downstream_in_month', default: 0 - t.integer 'qty_demands_finished_downstream_in_quarter', default: 0 - t.integer 'qty_demands_finished_downstream_in_semester', default: 0 - t.integer 'qty_demands_finished_downstream_in_year', default: 0 - t.integer 'qty_bugs_opened', default: 0 - t.integer 'qty_bugs_opened_in_month', default: 0 - t.integer 'qty_bugs_opened_in_quarter', default: 0 - t.integer 'qty_bugs_opened_in_semester', default: 0 - t.integer 'qty_bugs_opened_in_year', default: 0 - t.integer 'qty_bugs_closed', default: 0 - t.integer 'qty_bugs_closed_in_month', default: 0 - t.integer 'qty_bugs_closed_in_quarter', default: 0 - t.integer 'qty_bugs_closed_in_semester', default: 0 - t.integer 'qty_bugs_closed_in_year', default: 0 - t.decimal 'bugs_share', default: '0.0' - t.decimal 'bugs_share_in_month', default: '0.0' - t.decimal 'bugs_share_in_quarter', default: '0.0' - t.decimal 'bugs_share_in_semester', default: '0.0' - t.decimal 'bugs_share_in_year', default: '0.0' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.decimal 'development_consumed_hours', default: '0.0', null: false - t.decimal 'design_consumed_hours', default: '0.0', null: false - t.decimal 'management_consumed_hours', default: '0.0', null: false - t.decimal 'development_consumed_hours_in_month', default: '0.0', null: false - t.decimal 'design_consumed_hours_in_month', default: '0.0', null: false - t.decimal 'management_consumed_hours_in_month', default: '0.0', null: false - t.index ['last_data_in_month'], name: 'index_team_consolidations_on_last_data_in_month' - t.index ['last_data_in_week'], name: 'index_team_consolidations_on_last_data_in_week' - t.index ['last_data_in_year'], name: 'index_team_consolidations_on_last_data_in_year' - t.index %w[team_id consolidation_date], name: 'team_consolidation_unique', unique: true - t.index ['team_id'], name: 'index_team_consolidations_on_team_id' - end - - create_table 'team_members', force: :cascade do |t| - t.string 'name', null: false - t.decimal 'monthly_payment' - t.boolean 'billable', default: true - t.integer 'billable_type', default: 0 - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.date 'start_date' - t.date 'end_date' - t.string 'jira_account_user_email' - t.string 'jira_account_id' - t.integer 'company_id', null: false - t.integer 'user_id' - t.integer 'hours_per_month', default: 0 - t.index %w[company_id name jira_account_id], name: 'index_team_members_on_company_id_and_name_and_jira_account_id', unique: true - t.index ['company_id'], name: 'index_team_members_on_company_id' - t.index ['jira_account_id'], name: 'index_team_members_on_jira_account_id' - t.index ['jira_account_user_email'], name: 'index_team_members_on_jira_account_user_email' - t.index ['user_id'], name: 'index_team_members_on_user_id' - end - - create_table 'team_resource_allocations', force: :cascade do |t| - t.integer 'team_resource_id', null: false - t.integer 'team_id', null: false - t.decimal 'monthly_payment', null: false - t.date 'start_date', null: false - t.date 'end_date' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['team_id'], name: 'index_team_resource_allocations_on_team_id' - t.index ['team_resource_id'], name: 'index_team_resource_allocations_on_team_resource_id' - end - - create_table 'team_resources', force: :cascade do |t| - t.integer 'company_id', null: false - t.integer 'resource_type', null: false - t.string 'resource_name', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['company_id'], name: 'index_team_resources_on_company_id' - t.index ['resource_name'], name: 'index_team_resources_on_resource_name' - t.index ['resource_type'], name: 'index_team_resources_on_resource_type' - end - - create_table 'teams', force: :cascade do |t| - t.integer 'company_id', null: false - t.string 'name', null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.integer 'max_work_in_progress', default: 0, null: false - t.index %w[company_id name], name: 'index_teams_on_company_id_and_name', unique: true - t.index ['company_id'], name: 'index_teams_on_company_id' - end - - create_table 'user_company_roles', id: :serial, force: :cascade do |t| - t.integer 'user_id' - t.integer 'company_id' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.integer 'user_role', default: 0, null: false - t.date 'start_date' - t.date 'end_date' - t.string 'slack_user' - t.index ['company_id'], name: 'index_user_company_roles_on_company_id' - t.index ['id'], name: 'index_user_company_roles_on_id' - t.index %w[user_id company_id], name: 'index_user_company_roles_on_user_id_and_company_id', unique: true - t.index ['user_id'], name: 'index_user_company_roles_on_user_id' - t.index ['user_role'], name: 'index_user_company_roles_on_user_role' - end - - create_table 'user_invites', force: :cascade do |t| - t.integer 'company_id', null: false - t.integer 'invite_status', null: false - t.integer 'invite_type', null: false - t.integer 'invite_object_id', null: false - t.string 'invite_email', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['company_id'], name: 'index_user_invites_on_company_id' - t.index ['invite_email'], name: 'index_user_invites_on_invite_email' - t.index ['invite_object_id'], name: 'index_user_invites_on_invite_object_id' - t.index ['invite_status'], name: 'index_user_invites_on_invite_status' - t.index ['invite_type'], name: 'index_user_invites_on_invite_type' - end - - create_table 'user_plans', force: :cascade do |t| - t.integer 'user_id', null: false - t.integer 'plan_id', null: false - t.integer 'plan_billing_period', default: 0, null: false - t.decimal 'plan_value', default: '0.0', null: false - t.datetime 'start_at', precision: nil, null: false - t.datetime 'finish_at', precision: nil, null: false - t.boolean 'active', default: false, null: false - t.boolean 'paid', default: false, null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['plan_id'], name: 'index_user_plans_on_plan_id' - t.index ['user_id'], name: 'index_user_plans_on_user_id' - end - - create_table 'user_project_roles', force: :cascade do |t| - t.integer 'user_id', null: false - t.integer 'project_id', null: false - t.integer 'role_in_project', default: 0, null: false - t.datetime 'created_at', precision: nil, null: false - t.datetime 'updated_at', precision: nil, null: false - t.index ['project_id'], name: 'index_user_project_roles_on_project_id' - t.index %w[user_id project_id], name: 'index_user_project_roles_on_user_id_and_project_id', unique: true - t.index ['user_id'], name: 'index_user_project_roles_on_user_id' - end - - create_table 'users', id: :serial, force: :cascade do |t| - t.string 'first_name', null: false - t.string 'last_name', null: false - t.string 'email', null: false - t.string 'encrypted_password', null: false - t.string 'reset_password_token' - t.datetime 'reset_password_sent_at' - t.datetime 'remember_created_at' - t.integer 'sign_in_count', default: 0, null: false - t.datetime 'current_sign_in_at' - t.datetime 'last_sign_in_at' - t.inet 'current_sign_in_ip' - t.inet 'last_sign_in_ip' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.boolean 'admin', default: false, null: false - t.integer 'last_company_id' - t.boolean 'email_notifications', default: false, null: false - t.decimal 'user_money_credits', default: '0.0', null: false - t.string 'avatar' - t.index ['email'], name: 'index_users_on_email', unique: true - t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true - end - - add_foreign_key 'azure_custom_fields', 'azure_accounts' - add_foreign_key 'azure_projects', 'azure_teams' - add_foreign_key 'azure_teams', 'azure_product_configs' - add_foreign_key 'class_of_service_change_histories', 'demands' - add_foreign_key 'company_settings', 'companies' - add_foreign_key 'contract_consolidations', 'contracts' - add_foreign_key 'contract_estimation_change_histories', 'contracts' - add_foreign_key 'contracts', 'contracts' - add_foreign_key 'contracts', 'customers' - add_foreign_key 'contracts', 'products' - add_foreign_key 'customer_consolidations', 'customers' - add_foreign_key 'customers', 'companies' - add_foreign_key 'customers', 'customers' - add_foreign_key 'customers_devise_customers', 'customers' - add_foreign_key 'customers_devise_customers', 'dashboard' - add_foreign_key 'customers_projects', 'customers' - add_foreign_key 'customers_projects', 'projects' - add_foreign_key 'demand_block_notifications', 'demand_blocks' - add_foreign_key 'demand_blocks', 'demands' - add_foreign_key 'demand_blocks', 'risk_reviews' - add_foreign_key 'demand_blocks', 'stages' - add_foreign_key 'demand_blocks', 'team_members', column: 'blocker_id' - add_foreign_key 'demand_blocks', 'team_members', column: 'unblocker_id' - add_foreign_key 'demand_comments', 'demands' - add_foreign_key 'demand_comments', 'team_members' - add_foreign_key 'demand_efforts', 'demand_transitions' - add_foreign_key 'demand_efforts', 'demands' - add_foreign_key 'demand_efforts', 'item_assignments' - add_foreign_key 'demand_score_matrices', 'demands' - add_foreign_key 'demand_score_matrices', 'score_matrix_answers' - add_foreign_key 'demand_score_matrices', 'users' - add_foreign_key 'demand_transitions', 'demands' - add_foreign_key 'demand_transitions', 'stages' - add_foreign_key 'demand_transitions', 'team_members' - add_foreign_key 'demands', 'contracts' - add_foreign_key 'demands', 'customers' - add_foreign_key 'demands', 'portfolio_units' - add_foreign_key 'demands', 'products' - add_foreign_key 'demands', 'projects' - add_foreign_key 'demands', 'risk_reviews' - add_foreign_key 'demands', 'service_delivery_reviews' - add_foreign_key 'demands', 'stages', column: 'current_stage_id' - add_foreign_key 'demands', 'teams' - add_foreign_key 'financial_informations', 'companies' - add_foreign_key 'flow_events', 'projects' - add_foreign_key 'flow_events', 'risk_reviews' - add_foreign_key 'flow_events', 'users' - add_foreign_key 'initiative_consolidations', 'initiatives' - add_foreign_key 'initiatives', 'companies' - add_foreign_key 'integration_errors', 'companies' - add_foreign_key 'integration_errors', 'projects' - add_foreign_key 'item_assignments', 'demands' - add_foreign_key 'item_assignments', 'memberships' - add_foreign_key 'jira_accounts', 'companies' - add_foreign_key 'jira_api_errors', 'demands' - add_foreign_key 'jira_custom_field_mappings', 'jira_accounts' - add_foreign_key 'jira_portfolio_unit_configs', 'portfolio_units' - add_foreign_key 'jira_product_configs', 'companies' - add_foreign_key 'jira_product_configs', 'products' - add_foreign_key 'jira_project_configs', 'jira_product_configs' - add_foreign_key 'jira_project_configs', 'projects' - add_foreign_key 'memberships', 'team_members' - add_foreign_key 'memberships', 'teams' - add_foreign_key 'operations_dashboard_pairings', 'operations_dashboards' - add_foreign_key 'operations_dashboard_pairings', 'team_members', column: 'pair_id' - add_foreign_key 'operations_dashboards', 'demands', column: 'first_delivery_id' - add_foreign_key 'operations_dashboards', 'team_members' - add_foreign_key 'portfolio_units', 'portfolio_units', column: 'parent_id' - add_foreign_key 'portfolio_units', 'products' - add_foreign_key 'products', 'companies' - add_foreign_key 'products', 'customers' - add_foreign_key 'products_projects', 'products' - add_foreign_key 'products_projects', 'projects' - add_foreign_key 'project_broken_wip_logs', 'projects' - add_foreign_key 'project_change_deadline_histories', 'projects' - add_foreign_key 'project_change_deadline_histories', 'users' - add_foreign_key 'project_consolidations', 'projects' - add_foreign_key 'project_risk_alerts', 'project_risk_configs' - add_foreign_key 'project_risk_alerts', 'projects' - add_foreign_key 'projects', 'companies' - add_foreign_key 'projects', 'initiatives' - add_foreign_key 'projects', 'teams' - add_foreign_key 'replenishing_consolidations', 'projects' - add_foreign_key 'risk_review_action_items', 'memberships' - add_foreign_key 'risk_review_action_items', 'risk_reviews' - add_foreign_key 'risk_reviews', 'companies' - add_foreign_key 'risk_reviews', 'products' - add_foreign_key 'score_matrices', 'products' - add_foreign_key 'score_matrix_answers', 'score_matrix_questions' - add_foreign_key 'score_matrix_questions', 'score_matrices' - add_foreign_key 'service_delivery_reviews', 'companies' - add_foreign_key 'service_delivery_reviews', 'products' - add_foreign_key 'slack_configurations', 'teams' - add_foreign_key 'stage_project_configs', 'projects' - add_foreign_key 'stage_project_configs', 'stages' - add_foreign_key 'stages', 'companies' - add_foreign_key 'stages_teams', 'stages' - add_foreign_key 'stages_teams', 'teams' - add_foreign_key 'tasks', 'demands' - add_foreign_key 'team_consolidations', 'teams' - add_foreign_key 'team_members', 'companies' - add_foreign_key 'team_members', 'users' - add_foreign_key 'team_resource_allocations', 'team_resources' - add_foreign_key 'team_resource_allocations', 'teams' - add_foreign_key 'team_resources', 'companies' - add_foreign_key 'teams', 'companies' - add_foreign_key 'user_company_roles', 'companies' - add_foreign_key 'user_company_roles', 'users' - add_foreign_key 'user_invites', 'companies' - add_foreign_key 'user_plans', 'plans' - add_foreign_key 'user_plans', 'users' - add_foreign_key 'user_project_roles', 'projects' - add_foreign_key 'user_project_roles', 'users' - add_foreign_key 'users', 'companies', column: 'last_company_id' -end diff --git a/lib/tasks/consolidate_flows.rake b/lib/tasks/consolidate_flows.rake index cc31f7804..82ef01d0c 100644 --- a/lib/tasks/consolidate_flows.rake +++ b/lib/tasks/consolidate_flows.rake @@ -4,7 +4,7 @@ namespace :statistics do desc 'Data cache for projects' task consolidate_active_projects: :environment do if Time.zone.now.hour.odd? - Company.all.each do |company| + Company.find_each do |company| company.projects.active.finishing_after(Time.zone.today).each do |project| project.remove_outdated_consolidations Consolidations::ProjectConsolidationJob.perform_later(project) @@ -15,7 +15,7 @@ namespace :statistics do desc 'Consolidations for contracts' task consolidate_contracts: :environment do - Company.all.each do |company| + Company.find_each do |company| company.customers.each do |customer| customer.contracts.active(Time.zone.today).each do |contract| Consolidations::ContractConsolidationJob.perform_later(contract) @@ -26,7 +26,7 @@ namespace :statistics do desc 'Consolidations for customers' task consolidate_customers: :environment do - Company.all.each do |company| + Company.find_each do |company| company.customers.select(&:active?).each do |customer| Consolidations::CustomerConsolidationJob.perform_later(customer) end @@ -36,7 +36,7 @@ namespace :statistics do desc 'Consolidations for teams' task consolidate_teams: :environment do if Time.zone.now.hour.even? - Company.all.each do |company| + Company.find_each do |company| company.teams.select(&:active?).each do |team| Consolidations::TeamConsolidationJob.perform_later(team) end diff --git a/lib/tasks/create_initiative_consolidation.rake b/lib/tasks/create_initiative_consolidation.rake index 712185bd8..ee1d45acf 100644 --- a/lib/tasks/create_initiative_consolidation.rake +++ b/lib/tasks/create_initiative_consolidation.rake @@ -2,7 +2,7 @@ namespace :initiatives do task create_today_initiative_consolidation: :environment do - Initiative.all.each do |initiative| + Initiative.find_each do |initiative| Consolidations::InitiativeConsolidationJob.perform_later(initiative) end end diff --git a/lib/tasks/create_legacy_notifications.rake b/lib/tasks/create_legacy_notifications.rake index 34ee48776..76f641ff0 100644 --- a/lib/tasks/create_legacy_notifications.rake +++ b/lib/tasks/create_legacy_notifications.rake @@ -4,7 +4,7 @@ desc 'Create legacy notifications control' namespace :demand_block_notification do task create_legacy: :environment do - Company.all.each do |company| + Company.find_each do |company| company.projects.each do |project| project.demands.each do |demand| demand.demand_blocks.each do |block| diff --git a/lib/tasks/dashboards_cache_generator.rake b/lib/tasks/dashboards_cache_generator.rake index 003d4627a..58d856547 100644 --- a/lib/tasks/dashboards_cache_generator.rake +++ b/lib/tasks/dashboards_cache_generator.rake @@ -3,7 +3,7 @@ namespace :dashboards_cache do desc 'Generates operations cache - all time' task generate_operations_dashboard_cache_all_time: :environment do - TeamMember.all.each do |member| + TeamMember.find_each do |member| last_delivery = member.last_delivery first_pull = member.first_assignment last_pull = member.last_assignment diff --git a/lib/tasks/notifications.rake b/lib/tasks/notifications.rake index 732a7b05c..fbd6fe4a6 100644 --- a/lib/tasks/notifications.rake +++ b/lib/tasks/notifications.rake @@ -4,7 +4,7 @@ namespace :notifications do desc 'Notifications for the user' task slack_notifications: :environment do - Team.all.each do |team| + Team.find_each do |team| next if team.slack_configurations.blank? || Time.zone.today.saturday? || Time.zone.today.sunday? hour_now = Time.zone.now.hour @@ -27,7 +27,7 @@ namespace :notifications do end task slack_notifications_for_demands: :environment do - Team.all.each do |team| + Team.find_each do |team| next if team.slack_configurations.blank? || !team.active? Slack::DemandSlackNotificationsJob.perform_now(team) diff --git a/lib/tasks/process_jira_integration_errors.rake b/lib/tasks/process_jira_integration_errors.rake index 974fab44a..c9ed52867 100644 --- a/lib/tasks/process_jira_integration_errors.rake +++ b/lib/tasks/process_jira_integration_errors.rake @@ -3,7 +3,7 @@ namespace :jira_errors do desc 'Process Jira integration errors' task process_api_errors: :environment do - Jira::JiraApiError.where(processed: false).each do |jira_error| + Jira::JiraApiError.where(processed: false).find_each do |jira_error| demand = jira_error.demand if demand.jira_api_errors.count > 5 demand.jira_api_errors.map { |demand_jira_error| demand_jira_error.update(processed: true) } diff --git a/lib/tasks/update_azure_accounts.rake b/lib/tasks/update_azure_accounts.rake index 0d5a33904..2d02398e3 100644 --- a/lib/tasks/update_azure_accounts.rake +++ b/lib/tasks/update_azure_accounts.rake @@ -4,7 +4,7 @@ namespace :azure do desc 'update azure accounts' task update_azure_accounts: :environment do - Azure::AzureAccount.all.each do |account| + Azure::AzureAccount.find_each do |account| Azure::AzureSyncJob.perform_later(account, nil, nil) end end diff --git a/lib/tasks/update_item_assignments.rake b/lib/tasks/update_item_assignments.rake index dda6f9915..9240242c1 100644 --- a/lib/tasks/update_item_assignments.rake +++ b/lib/tasks/update_item_assignments.rake @@ -4,7 +4,7 @@ desc 'Update item_assignments' namespace :item_assignments do task save_to_update_effort: :environment do - Membership.all.each do |member| + Membership.find_each do |member| member.item_assignments.map(&:save) end end diff --git a/spec/adapters/azure/azure_project_adapter_spec.rb b/spec/adapters/azure/azure_project_adapter_spec.rb index d289f41e0..8540ede26 100644 --- a/spec/adapters/azure/azure_project_adapter_spec.rb +++ b/spec/adapters/azure/azure_project_adapter_spec.rb @@ -25,10 +25,10 @@ it 'creates the product and the azure config for it' do mocked_azure_return = file_fixture('azure_teams_list.json').read allow(HTTParty).to(receive(:get)).once { JSON.parse(mocked_azure_return) } - expect(described_class.new(azure_account).products).to eq [Product.all.first] - expect(Azure::AzureTeam.all.count).not_to be_zero - expect(Azure::AzureProject.all.count).not_to be_zero - expect(Azure::AzureProductConfig.all.count).not_to be_zero + expect(described_class.new(azure_account).products).to eq [Product.first] + expect(Azure::AzureTeam.count).not_to be_zero + expect(Azure::AzureProject.count).not_to be_zero + expect(Azure::AzureProductConfig.count).not_to be_zero end end end diff --git a/spec/adapters/azure/azure_work_item_adapter_spec.rb b/spec/adapters/azure/azure_work_item_adapter_spec.rb index 6bd3a2899..33ffd2b19 100644 --- a/spec/adapters/azure/azure_work_item_adapter_spec.rb +++ b/spec/adapters/azure/azure_work_item_adapter_spec.rb @@ -91,9 +91,9 @@ described_class.new(azure_account).work_item(2, azure_product_config.azure_team.azure_project) - expect(PortfolioUnit.all.count).to eq 1 - expect(Demand.all.count).to eq 1 - expect(Task.all.count).to eq 1 + expect(PortfolioUnit.count).to eq 1 + expect(Demand.count).to eq 1 + expect(Task.count).to eq 1 expect(PortfolioUnit.all.map(&:name)).to eq ['This Is An Epic'] @@ -138,8 +138,8 @@ described_class.new(azure_account).work_item(2, azure_product_config.azure_team.azure_project) - expect(Demand.all.count).to eq 1 - expect(Task.all.count).to eq 1 + expect(Demand.count).to eq 1 + expect(Task.count).to eq 1 expect(demand.reload.discarded_at).not_to be_nil expect(task.reload.discarded_at).not_to be_nil @@ -168,8 +168,8 @@ described_class.new(azure_account).work_item(2, azure_product_config.azure_team.azure_project) - expect(Demand.all.count).to eq 1 - expect(Task.all.count).to eq 1 + expect(Demand.count).to eq 1 + expect(Task.count).to eq 1 expect(demand.reload.discarded_at).to be_nil expect(task.reload.discarded_at).to be_nil @@ -208,9 +208,9 @@ described_class.new(azure_account).work_item(2, azure_product_config.azure_team.azure_project) - expect(PortfolioUnit.all.count).to eq 1 - expect(Demand.all.count).to eq 2 - expect(Task.all.count).to eq 1 + expect(PortfolioUnit.count).to eq 1 + expect(Demand.count).to eq 2 + expect(Task.count).to eq 1 end end @@ -233,8 +233,8 @@ described_class.new(azure_account).work_item(2, azure_product_config.azure_team.azure_project) - expect(Task.all.count).to eq 0 - expect(Demand.all.count).to eq 0 + expect(Task.count).to eq 0 + expect(Demand.count).to eq 0 end end end @@ -298,8 +298,8 @@ expect(Rails.logger).to(receive(:error)).once described_class.new(azure_account).work_item(1, azure_product_config.azure_team.azure_project) - expect(Demand.all.count).to be_zero - expect(PortfolioUnit.all.count).to be_zero + expect(Demand.count).to be_zero + expect(PortfolioUnit.count).to be_zero end end end diff --git a/spec/adapters/azure/azure_work_item_updates_adapter_spec.rb b/spec/adapters/azure/azure_work_item_updates_adapter_spec.rb index d8f8a792b..6afad4aa7 100644 --- a/spec/adapters/azure/azure_work_item_updates_adapter_spec.rb +++ b/spec/adapters/azure/azure_work_item_updates_adapter_spec.rb @@ -27,10 +27,10 @@ expect(Stage.all.map(&:name)).to match_array ['To Do', 'Doing', 'Done'] expect(Stage.all.map { |s| [s.name, s.projects] }).to match_array [['To Do', [demand.project]], ['Doing', [demand.project]], ['Done', [demand.project]]] - expect(DemandTransition.all.order(:id).map(&:last_time_in)).to eq %w[2022-01-13T14:05:06.22Z 2022-01-17T13:34:43.95Z 2022-01-24T15:02:14.39Z] - expect(DemandTransition.all.order(:id).map(&:last_time_out)).to eq ['2022-01-17T13:34:43.95Z', '2022-01-24T15:02:14.39Z', nil] - expect(TeamMember.all.order(:id).map(&:name)).to eq ['Celso Martins'] - expect(TeamMember.all.order(:id).map(&:user_id)).to eq [user.id] + expect(DemandTransition.order(:id).map(&:last_time_in)).to eq %w[2022-01-13T14:05:06.22Z 2022-01-17T13:34:43.95Z 2022-01-24T15:02:14.39Z] + expect(DemandTransition.order(:id).map(&:last_time_out)).to eq ['2022-01-17T13:34:43.95Z', '2022-01-24T15:02:14.39Z', nil] + expect(TeamMember.order(:id).map(&:name)).to eq ['Celso Martins'] + expect(TeamMember.order(:id).map(&:user_id)).to eq [user.id] end end @@ -48,10 +48,10 @@ expect(Stage.all.map(&:name)).to match_array ['To Do', 'Doing', 'Done'] expect(Stage.all.map { |s| [s.name, s.projects] }).to match_array [['To Do', [demand.project]], ['Doing', [demand.project]], ['Done', [demand.project]]] - expect(DemandTransition.all.order(:id).map(&:last_time_in)).to eq %w[2022-01-13T14:05:06.22Z 2022-01-17T13:34:43.95Z 2022-01-24T15:02:14.39Z] - expect(DemandTransition.all.order(:id).map(&:last_time_out)).to eq ['2022-01-17T13:34:43.95Z', '2022-01-24T15:02:14.39Z', nil] - expect(TeamMember.all.order(:id).map(&:name)).to eq ['Celso Martins'] - expect(TeamMember.all.order(:id).map(&:user_id)).to eq [user.id] + expect(DemandTransition.order(:id).map(&:last_time_in)).to eq %w[2022-01-13T14:05:06.22Z 2022-01-17T13:34:43.95Z 2022-01-24T15:02:14.39Z] + expect(DemandTransition.order(:id).map(&:last_time_out)).to eq ['2022-01-17T13:34:43.95Z', '2022-01-24T15:02:14.39Z', nil] + expect(TeamMember.order(:id).map(&:name)).to eq ['Celso Martins'] + expect(TeamMember.order(:id).map(&:user_id)).to eq [user.id] expect(demand.discarded_at).to eq '2022-01-24T15:02:14.39Z' end end diff --git a/spec/controllers/azure/azure_custom_fields_controller_spec.rb b/spec/controllers/azure/azure_custom_fields_controller_spec.rb index 79cd56b31..33f151bd0 100644 --- a/spec/controllers/azure/azure_custom_fields_controller_spec.rb +++ b/spec/controllers/azure/azure_custom_fields_controller_spec.rb @@ -74,7 +74,7 @@ delete :destroy, params: { company_id: company, id: custom_field }, xhr: true - expect(Azure::AzureCustomField.all.count).to eq 0 + expect(Azure::AzureCustomField.count).to eq 0 expect(response).to render_template 'azure/azure_custom_fields/destroy' end end diff --git a/spec/controllers/demand_transitions_controller_spec.rb b/spec/controllers/demand_transitions_controller_spec.rb index 2d4f8c71c..4c2da90e2 100644 --- a/spec/controllers/demand_transitions_controller_spec.rb +++ b/spec/controllers/demand_transitions_controller_spec.rb @@ -126,7 +126,7 @@ expect(assigns(:stages_to_select)).to eq [second_stage, first_stage] expect(demand.reload.current_stage).to eq stage - expect(ProjectBrokenWipLog.all.count).to eq 0 + expect(ProjectBrokenWipLog.count).to eq 0 end end @@ -152,7 +152,7 @@ it 'creates the new demand transition and does not create the new broken wip log' do expect(response).to render_template 'demand_transitions/create' - expect(ProjectBrokenWipLog.all.count).to eq 1 + expect(ProjectBrokenWipLog.count).to eq 1 end end end @@ -162,7 +162,7 @@ before { post :create, params: { company_id: company, demand_id: demand, demand_transition: { stage_id: nil, last_time_in: nil, last_time_out: nil } }, xhr: true } it 'does not create the transition and re-render the template with the errors' do - expect(DemandTransition.all.count).to eq 0 + expect(DemandTransition.count).to eq 0 expect(response).to render_template 'demand_transitions/create' expect(assigns(:demand_transition).errors.full_messages).to eq ['Etapa deve existir', 'Entrada não pode ficar em branco'] end diff --git a/spec/controllers/demands_controller_spec.rb b/spec/controllers/demands_controller_spec.rb index f68211487..60fdfc715 100644 --- a/spec/controllers/demands_controller_spec.rb +++ b/spec/controllers/demands_controller_spec.rb @@ -525,7 +525,7 @@ delete :destroy_physically, params: { company_id: company, id: demand }, xhr: true expect(response).to render_template 'demands/destroy_physically' - expect(Demand.all.count).to eq 0 + expect(Demand.count).to eq 0 end end diff --git a/spec/controllers/jira/jira_custom_field_mappings_controller_spec.rb b/spec/controllers/jira/jira_custom_field_mappings_controller_spec.rb index 9412bae51..0342845cc 100644 --- a/spec/controllers/jira/jira_custom_field_mappings_controller_spec.rb +++ b/spec/controllers/jira/jira_custom_field_mappings_controller_spec.rb @@ -90,7 +90,7 @@ before { post :create, params: { company_id: company, jira_account_id: jira_account, jira_jira_custom_field_mapping: { custom_field_type: nil, custom_field_machine_name: nil } }, xhr: true } it 'does not create the jira custom field and re-render the template with the errors' do - expect(Jira::JiraCustomFieldMapping.all.count).to eq 0 + expect(Jira::JiraCustomFieldMapping.count).to eq 0 expect(response).to render_template 'jira/jira_custom_field_mappings/create' expect(assigns(:jira_custom_field_mapping).errors.full_messages).to eq ['Machine Name do Jira não pode ficar em branco', 'Tipo do Campo não pode ficar em branco'] end @@ -186,7 +186,7 @@ it 'deletes the jira custom field mapping and renders the template' do delete :destroy, params: { company_id: company, jira_account_id: jira_account, id: jira_custom_field_mapping }, xhr: true - expect(Jira::JiraCustomFieldMapping.all.count).to eq 0 + expect(Jira::JiraCustomFieldMapping.count).to eq 0 expect(response).to render_template 'jira/jira_custom_field_mappings/destroy' end end diff --git a/spec/controllers/risk_review_action_items_controller_spec.rb b/spec/controllers/risk_review_action_items_controller_spec.rb index a2419041f..e5e231ea0 100644 --- a/spec/controllers/risk_review_action_items_controller_spec.rb +++ b/spec/controllers/risk_review_action_items_controller_spec.rb @@ -119,7 +119,7 @@ it 'does not create the review and re-render the template with the errors' do post :create, params: { company_id: company, product_id: product, risk_review_id: risk_review, risk_review_action_item: { created_date: nil, deadline: nil, description: nil, membership_id: nil, action_type: nil } }, xhr: true - expect(RiskReviewActionItem.all.count).to eq 3 + expect(RiskReviewActionItem.count).to eq 3 expect(response).to render_template 'risk_review_action_items/create' expect(assigns(:risk_review_action_item).errors.full_messages).to eq ['Responsável deve existir', 'Dt Criação não pode ficar em branco', 'Tipo da Ação não pode ficar em branco', 'Descrição não pode ficar em branco', 'Prazo não pode ficar em branco'] end diff --git a/spec/controllers/risk_reviews_controller_spec.rb b/spec/controllers/risk_reviews_controller_spec.rb index 8339c3075..ec10cb003 100644 --- a/spec/controllers/risk_reviews_controller_spec.rb +++ b/spec/controllers/risk_reviews_controller_spec.rb @@ -137,7 +137,7 @@ expect(RiskReviewGeneratorJob).not_to receive(:perform_later) post :create, params: { company_id: company, product_id: product, risk_review: { meeting_date: nil, lead_time_outlier_limit: nil } }, xhr: true - expect(RiskReview.all.count).to eq 0 + expect(RiskReview.count).to eq 0 expect(response).to render_template 'risk_reviews/create' expect(assigns(:risk_review).errors.full_messages).to eq ['Outlier no lead time não pode ficar em branco', 'Data da Reunião não pode ficar em branco'] end diff --git a/spec/controllers/score_matrix_answers_controller_spec.rb b/spec/controllers/score_matrix_answers_controller_spec.rb index fb69e57bb..861717a66 100644 --- a/spec/controllers/score_matrix_answers_controller_spec.rb +++ b/spec/controllers/score_matrix_answers_controller_spec.rb @@ -106,7 +106,7 @@ it 'deletes the score matrix' do expect(response).to render_template 'score_matrix_answers/_score_matrix_answers_table' expect(response).to render_template 'score_matrix_answers/destroy' - expect(ScoreMatrixAnswer.all.count).to eq 4 + expect(ScoreMatrixAnswer.count).to eq 4 expect(assigns(:score_matrix_answers)).to eq [third_score_matrix_answer, second_score_matrix_answer, first_score_matrix_answer, fourth_score_matrix_answer] end end diff --git a/spec/controllers/score_matrix_questions_controller_spec.rb b/spec/controllers/score_matrix_questions_controller_spec.rb index 249e29dd9..65a18d760 100644 --- a/spec/controllers/score_matrix_questions_controller_spec.rb +++ b/spec/controllers/score_matrix_questions_controller_spec.rb @@ -182,7 +182,7 @@ it 'deletes the score matrix' do expect(response).to render_template 'score_matrix_questions/destroy' - expect(ScoreMatrixQuestion.all.count).to eq 4 + expect(ScoreMatrixQuestion.count).to eq 4 expect(assigns(:score_matrix_questions)).to eq [first_score_matrix_question, fourth_score_matrix_question, second_score_matrix_question, third_score_matrix_question] end end diff --git a/spec/controllers/slack_configurations_controller_spec.rb b/spec/controllers/slack_configurations_controller_spec.rb index e4f9a72fc..c71b04961 100644 --- a/spec/controllers/slack_configurations_controller_spec.rb +++ b/spec/controllers/slack_configurations_controller_spec.rb @@ -261,7 +261,7 @@ delete :destroy, params: { company_id: company, id: config } expect(flash[:notice]).to eq I18n.t('slack_configurations.destroy.success') - expect(SlackConfiguration.all.count).to eq 2 + expect(SlackConfiguration.count).to eq 2 end end diff --git a/spec/controllers/team_resource_allocations_controller_spec.rb b/spec/controllers/team_resource_allocations_controller_spec.rb index f2a2b6da8..c4a96fc99 100644 --- a/spec/controllers/team_resource_allocations_controller_spec.rb +++ b/spec/controllers/team_resource_allocations_controller_spec.rb @@ -84,8 +84,8 @@ before { post :create, params: { company_id: company, team_id: team, team_resource_allocation: { team_resource_id: nil, start_date: nil, end_date: nil, monthly_payment: nil } }, xhr: true } it 'does not create the team member allocation and re-render the template with the errors' do - expect(TeamResource.all.count).to eq 1 - expect(TeamResourceAllocation.all.count).to eq 0 + expect(TeamResource.count).to eq 1 + expect(TeamResourceAllocation.count).to eq 0 expect(response).to render_template 'team_resource_allocations/create' expect(assigns(:team_resource_allocation).errors.full_messages).to eq ['Recurso do Time deve existir', 'Início não pode ficar em branco', 'Pagamento Mensal não pode ficar em branco'] end diff --git a/spec/controllers/team_resources_controller_spec.rb b/spec/controllers/team_resources_controller_spec.rb index 0c53bb457..c693e4fcf 100644 --- a/spec/controllers/team_resources_controller_spec.rb +++ b/spec/controllers/team_resources_controller_spec.rb @@ -76,7 +76,7 @@ before { post :create, params: { company_id: company, team_resource: { resource_type: nil } }, xhr: true } it 'does not create the team resource and re-render the template with the errors' do - expect(TeamResource.all.count).to eq 0 + expect(TeamResource.count).to eq 0 expect(response).to render_template 'team_resources/create' expect(assigns(:team_resource).errors.full_messages).to eq ['Tipo do Recurso não pode ficar em branco'] end diff --git a/spec/graphql/types/mutation_type_spec.rb b/spec/graphql/types/mutation_type_spec.rb index 59e70f1b3..bc5393f55 100644 --- a/spec/graphql/types/mutation_type_spec.rb +++ b/spec/graphql/types/mutation_type_spec.rb @@ -116,7 +116,7 @@ it 'succeeds' do result = FlowClimateSchema.execute(mutation).as_json expect(result['data']['deleteTeam']['statusMessage']).to eq('SUCCESS') - expect(Team.all.count).to eq 0 + expect(Team.count).to eq 0 end end @@ -171,7 +171,7 @@ it 'succeeds' do result = FlowClimateSchema.execute(mutation).as_json expect(result['data']['deleteTeamMember']['statusMessage']).to eq('SUCCESS') - expect(TeamMember.all.count).to eq 0 + expect(TeamMember.count).to eq 0 end end @@ -180,7 +180,7 @@ allow(TeamMember).to(receive(:find_by)).and_return(nil) result = FlowClimateSchema.execute(mutation).as_json expect(result['data']['deleteTeamMember']['statusMessage']).to eq('FAIL') - expect(TeamMember.all.count).to eq 1 + expect(TeamMember.count).to eq 1 end end @@ -665,7 +665,7 @@ it 'succeeds' do result = FlowClimateSchema.execute(mutation).as_json expect(result['data']['deleteWorkItemType']['statusMessage']).to eq('SUCCESS') - expect(WorkItemType.all.count).to eq 0 + expect(WorkItemType.count).to eq 0 end end @@ -840,7 +840,7 @@ it 'succeeds' do result = FlowClimateSchema.execute(mutation).as_json expect(result['data']['deleteProductRiskReview']['statusMessage']).to eq('SUCCESS') - expect(RiskReview.all.count).to eq 0 + expect(RiskReview.count).to eq 0 end end diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 4358f8674..3e173b0a0 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -1034,7 +1034,7 @@ demands_external_ids = Demand.finished_with_leadtime.order(end_date: :asc).map(&:external_id) demands_lead_times = Demand.finished_with_leadtime.order(end_date: :asc).map { |demand| demand.leadtime.to_f } - demands_ids = Demand.all.order(:created_date).map(&:id) + demands_ids = Demand.order(:created_date).map(&:id) lead_time_p65 = Stats::StatisticsService.instance.percentile(65, demands_lead_times) lead_time_p80 = Stats::StatisticsService.instance.percentile(80, demands_lead_times) diff --git a/spec/helpers/demand_blocks_helper_spec.rb b/spec/helpers/demand_blocks_helper_spec.rb index b034da31b..d5152a029 100644 --- a/spec/helpers/demand_blocks_helper_spec.rb +++ b/spec/helpers/demand_blocks_helper_spec.rb @@ -5,7 +5,7 @@ let(:team_member) { Fabricate :team_member, name: 'zzz' } let(:other_team_member) { Fabricate :team_member, name: 'aaa' } - it { expect(helper.team_members_options(TeamMember.all, team_member.id)).to eq options_for_select(TeamMember.all.order(:name).map { |member| [member.name, member.id] }, team_member.id) } + it { expect(helper.team_members_options(TeamMember.all, team_member.id)).to eq options_for_select(TeamMember.order(:name).map { |member| [member.name, member.id] }, team_member.id) } it { expect(helper.team_members_options(TeamMember.none, nil)).to eq options_for_select([]) } end @@ -13,7 +13,7 @@ let(:stage) { Fabricate :stage, name: 'zzz' } let(:other_stage) { Fabricate :stage, name: 'aaa' } - it { expect(helper.stage_options(Stage.all, stage.id)).to eq options_for_select(Stage.all.order(:name).map { |stage| [stage.name, stage.id] }, stage.id) } + it { expect(helper.stage_options(Stage.all, stage.id)).to eq options_for_select(Stage.order(:name).map { |stage| [stage.name, stage.id] }, stage.id) } it { expect(helper.stage_options(Stage.none, nil)).to eq options_for_select([]) } end @@ -21,7 +21,7 @@ let(:project) { Fabricate :project, name: 'zzz' } let(:other_project) { Fabricate :project, name: 'aaa' } - it { expect(helper.project_options(Project.all, project.id)).to eq options_for_select(Project.all.order(:name).map { |project| [project.name, project.id] }, project.id) } + it { expect(helper.project_options(Project.all, project.id)).to eq options_for_select(Project.order(:name).map { |project| [project.name, project.id] }, project.id) } it { expect(helper.project_options(Project.none, nil)).to eq options_for_select([]) } end end diff --git a/spec/jobs/consolidations/contract_consolidation_job_spec.rb b/spec/jobs/consolidations/contract_consolidation_job_spec.rb index 2c1429bbc..9eb90e4b0 100644 --- a/spec/jobs/consolidations/contract_consolidation_job_spec.rb +++ b/spec/jobs/consolidations/contract_consolidation_job_spec.rb @@ -30,7 +30,7 @@ described_class.perform_now(contract) - new_consolidations = Consolidations::ContractConsolidation.all.order(:consolidation_date) + new_consolidations = Consolidations::ContractConsolidation.order(:consolidation_date) expect(new_consolidations.count).to eq 4 expect(new_consolidations[0].operational_risk_value).to eq 1 @@ -49,7 +49,7 @@ described_class.perform_now(contract) - new_consolidations = Consolidations::ContractConsolidation.all.order(:consolidation_date) + new_consolidations = Consolidations::ContractConsolidation.order(:consolidation_date) expect(new_consolidations.count).to eq 4 expect(new_consolidations[0].operational_risk_value).to eq 1 diff --git a/spec/jobs/consolidations/replenishing_consolidation_job_spec.rb b/spec/jobs/consolidations/replenishing_consolidation_job_spec.rb index e07d73777..bbf14e797 100644 --- a/spec/jobs/consolidations/replenishing_consolidation_job_spec.rb +++ b/spec/jobs/consolidations/replenishing_consolidation_job_spec.rb @@ -34,7 +34,7 @@ allow(Stats::StatisticsService.instance).to(receive(:run_montecarlo)).and_return([4, 3, 6, 10]) described_class.perform_now - new_consolidations = Consolidations::ReplenishingConsolidation.all.order(:consolidation_date) + new_consolidations = Consolidations::ReplenishingConsolidation.order(:consolidation_date) expect(new_consolidations.count).to eq 2 expect(new_consolidations.map(&:consolidation_date)).to eq [Time.zone.today, Time.zone.today] @@ -77,7 +77,7 @@ allow(Stats::StatisticsService.instance).to(receive(:run_montecarlo)).and_return([4, 3, 6, 10]) described_class.perform_now(team.id) - new_consolidations = Consolidations::ReplenishingConsolidation.all.order(:consolidation_date) + new_consolidations = Consolidations::ReplenishingConsolidation.order(:consolidation_date) expect(new_consolidations.count).to eq 2 expect(new_consolidations.map(&:consolidation_date)).to eq [Time.zone.today, Time.zone.today] @@ -107,7 +107,7 @@ travel_to Time.zone.local(2020, 7, 8, 10, 0, 0) do described_class.perform_now - new_consolidations = Consolidations::ReplenishingConsolidation.all.order(:consolidation_date) + new_consolidations = Consolidations::ReplenishingConsolidation.order(:consolidation_date) expect(new_consolidations.count).to eq 0 end end @@ -118,7 +118,7 @@ expect(Rails.logger).to(receive(:warn)).once described_class.perform_now('foo') - new_consolidations = Consolidations::ReplenishingConsolidation.all.order(:consolidation_date) + new_consolidations = Consolidations::ReplenishingConsolidation.order(:consolidation_date) expect(new_consolidations.count).to eq 0 end end diff --git a/spec/jobs/slack/slack_notifications_job_spec.rb b/spec/jobs/slack/slack_notifications_job_spec.rb index cfee382f0..3ebe83210 100644 --- a/spec/jobs/slack/slack_notifications_job_spec.rb +++ b/spec/jobs/slack/slack_notifications_job_spec.rb @@ -109,12 +109,12 @@ context 'with monthly_team_efficiency_retrospective notification' do before { travel_to Time.zone.now.end_of_month + 1.day } + it 'calls slack notification method' do expect_any_instance_of(Slack::SlackNotificationService).to receive(:notify_team_efficiency).once described_class.perform_now(tenth_slack_config, team) end end - end end diff --git a/spec/models/flow/contracts_flow_information_spec.rb b/spec/models/flow/contracts_flow_information_spec.rb index d57b38747..f3cccc0d7 100644 --- a/spec/models/flow/contracts_flow_information_spec.rb +++ b/spec/models/flow/contracts_flow_information_spec.rb @@ -292,7 +292,7 @@ Fabricate :demand_block, demand: demand, block_time: 34.days.ago, unblock_time: 31.days.ago Fabricate :demand_block, demand: other_demand, block_time: 38.days.ago, unblock_time: 37.days.ago - Demand.all.each { |demand_to_effort| DemandEffortService.instance.build_efforts_to_demand(demand_to_effort) } + Demand.find_each { |demand_to_effort| DemandEffortService.instance.build_efforts_to_demand(demand_to_effort) } contract_flow = described_class.new(contract) diff --git a/spec/readers/azure/azure_reader_spec.rb b/spec/readers/azure/azure_reader_spec.rb index bb24cace3..85b7cc11a 100644 --- a/spec/readers/azure/azure_reader_spec.rb +++ b/spec/readers/azure/azure_reader_spec.rb @@ -10,7 +10,7 @@ described_class.instance.read_team(company, azure_account, JSON.parse(azure_item_return)) - expect(Team.all.count).to eq 0 + expect(Team.count).to eq 0 end end @@ -72,7 +72,7 @@ described_class.instance.read_customer(company, JSON.parse(azure_item_return)) - expect(Customer.all.count).to eq 1 + expect(Customer.count).to eq 1 end end end @@ -96,7 +96,7 @@ described_class.instance.read_initiative(company, JSON.parse(azure_item_return)) - expect(Initiative.all.count).to be_zero + expect(Initiative.count).to be_zero end end @@ -108,7 +108,7 @@ described_class.instance.read_initiative(company, JSON.parse(azure_item_return)) - expect(Initiative.all.count).to eq 1 + expect(Initiative.count).to eq 1 end end end diff --git a/spec/services/demand_effort_service_spec.rb b/spec/services/demand_effort_service_spec.rb index 2338fe0ce..83fce2beb 100644 --- a/spec/services/demand_effort_service_spec.rb +++ b/spec/services/demand_effort_service_spec.rb @@ -26,9 +26,9 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 - expect(DemandEffort.all.sum(&:effort_value)).to be_within(0.1).of(2.5) - expect(DemandEffort.all.sum(&:total_blocked)).to eq 0 + expect(DemandEffort.count).to eq 2 + expect(DemandEffort.sum(&:effort_value)).to be_within(0.1).of(2.5) + expect(DemandEffort.sum(&:total_blocked)).to eq 0 expect(demand.reload.effort_development).to be_within(0.1).of(2.5) expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -52,9 +52,9 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 - expect(DemandEffort.all.sum(&:effort_value)).to be_within(0.1).of(1.3) - expect(DemandEffort.all.sum(&:total_blocked)).to eq 0 + expect(DemandEffort.count).to eq 2 + expect(DemandEffort.sum(&:effort_value)).to be_within(0.1).of(1.3) + expect(DemandEffort.sum(&:total_blocked)).to eq 0 expect(demand.reload.effort_development).to be_within(0.1).of(1.3) expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -72,8 +72,8 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 1 - expect(DemandEffort.all.sum(&:effort_value)).to eq 2.4 + expect(DemandEffort.count).to eq 1 + expect(DemandEffort.sum(&:effort_value)).to eq 2.4 expect(demand.reload.effort_development).to eq 2.4 expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -90,8 +90,8 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 - expect(DemandEffort.all.sum(&:effort_value)).to eq 9 + expect(DemandEffort.count).to eq 2 + expect(DemandEffort.sum(&:effort_value)).to eq 9 expect(demand.reload.effort_development).to eq 9 expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -107,8 +107,8 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 1 - expect(DemandEffort.all.sum(&:effort_value)).to eq 1.2 + expect(DemandEffort.count).to eq 1 + expect(DemandEffort.sum(&:effort_value)).to eq 1.2 expect(demand.reload.effort_development).to eq 1.2 expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -124,8 +124,8 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 1 - expect(DemandEffort.all.sum(&:effort_value)).to eq 2.4 + expect(DemandEffort.count).to eq 1 + expect(DemandEffort.sum(&:effort_value)).to eq 2.4 expect(demand.reload.effort_development).to eq 2.4 expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -141,8 +141,8 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 1 - expect(DemandEffort.all.sum(&:effort_value)).to eq 1.2 + expect(DemandEffort.count).to eq 1 + expect(DemandEffort.sum(&:effort_value)).to eq 1.2 expect(demand.reload.effort_development).to eq 1.2 expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -164,8 +164,8 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 - expect(DemandEffort.all.sum(&:effort_value)).to be_within(0.1).of(9.5) + expect(DemandEffort.count).to eq 2 + expect(DemandEffort.sum(&:effort_value)).to be_within(0.1).of(9.5) expect(demand.reload.effort_upstream).to be_within(0.1).of(9.5) expect(demand.reload.effort_downstream).to eq 0 expect(demand.reload.effort_development).to be_within(0.1).of(9.5) @@ -192,7 +192,7 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 + expect(DemandEffort.count).to eq 2 expect(DemandEffort.all.map { |effort| effort.effort_value.to_f }).to eq [2.56, 4.819999999999999] expect(DemandEffort.all.map { |effort| effort.total_blocked.to_f }).to eq [7.016666666666667, 0.9833333333333333] expect(demand.reload.effort_upstream.to_f).to eq 7.379999999999999 @@ -258,9 +258,9 @@ described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 3 - expect(DemandEffort.all.sum(&:effort_value)).to be_within(0.1).of(18.21) - expect(DemandEffort.all.sum(&:total_blocked)).to eq 0 + expect(DemandEffort.count).to eq 3 + expect(DemandEffort.sum(&:effort_value)).to be_within(0.1).of(18.21) + expect(DemandEffort.sum(&:total_blocked)).to eq 0 expect(demand.reload.effort_development).to be_within(0.1).of(18.21) expect(demand.reload.effort_design).to eq 0 expect(demand.reload.effort_management).to eq 0 @@ -276,8 +276,8 @@ Fabricate :item_assignment, demand: demand, membership: dev_membership, start_time: Time.zone.local(2022, 12, 5, 18, 30), finish_time: Time.zone.local(2022, 12, 6, 10, 46) described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 - expect(DemandEffort.all.sum(&:effort_value)).to eq 4.25 + expect(DemandEffort.count).to eq 2 + expect(DemandEffort.sum(&:effort_value)).to eq 4.25 end end @@ -290,8 +290,8 @@ Fabricate :item_assignment, demand: demand, membership: dev_membership, start_time: Time.zone.local(2022, 12, 5, 11, 30), finish_time: Time.zone.local(2022, 12, 6, 10, 46) described_class.instance.build_efforts_to_demand(demand) - expect(DemandEffort.all.count).to eq 2 - expect(DemandEffort.all.sum(&:effort_value)).to eq 8.75 + expect(DemandEffort.count).to eq 2 + expect(DemandEffort.sum(&:effort_value)).to eq 8.75 end end end diff --git a/spec/services/slack/slack_notification_service_spec.rb b/spec/services/slack/slack_notification_service_spec.rb index 6bc681524..01a230d21 100644 --- a/spec/services/slack/slack_notification_service_spec.rb +++ b/spec/services/slack/slack_notification_service_spec.rb @@ -438,7 +438,7 @@ expect_any_instance_of(Slack::Notifier).not_to receive(:post) described_class.instance.notify_item_blocked(demand_block, 'http://foo.com', 'http://bar.com') - expect(Notifications::DemandBlockNotification.all.count).to eq 1 + expect(Notifications::DemandBlockNotification.count).to eq 1 end end @@ -453,7 +453,7 @@ expect_any_instance_of(Slack::Notifier).to receive(:post) described_class.instance.notify_item_blocked(demand_block, 'http://foo.com', 'http://bar.com') - expect(Notifications::DemandBlockNotification.all.count).to eq 1 + expect(Notifications::DemandBlockNotification.count).to eq 1 end end @@ -469,7 +469,7 @@ expect_any_instance_of(Slack::Notifier).to receive(:post) described_class.instance.notify_item_blocked(demand_block, 'http://foo.com', 'http://bar.com', 'unblocked') - expect(Notifications::DemandBlockNotification.all.count).to eq 1 + expect(Notifications::DemandBlockNotification.count).to eq 1 end end