Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails5 ActiveRecord monkey patch for SchemaDumper #2571

Merged
merged 9 commits into from
Jun 24, 2020
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

# Extract the Ruby version from the Gemfile.lock
- name: 'Determine Ruby Version'
run: echo ::set-env name=RUBY_VERSION::$(echo `cat ./Gemfile.lock | grep -A 1 'RUBY VERSION' | grep 'ruby' | grep -oE '[0-9]\.[0-9]'`)
run: echo ::set-env name=RUBY_VERSION::$(echo `cat ./Gemfile.lock | grep -A 1 'RUBY VERSION' | grep 'ruby' | grep -oE '[0-9]\.[0-9]'`)

# Install Ruby - using the version found in the Gemfile.lock
- name: 'Install Ruby'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ gem "pg", group: :pgsql, require: false
# Bit fields for ActiveRecord (https://github.com/pboling/flag_shih_tzu)
gem "flag_shih_tzu" #, "~> 0.3.23"

# Required for the `import` statements at the top of the Stat generators
gem "activerecord-import"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this gem is for the bulk-import of data and generating minimal SQL statements rather than for the Ruby-import keyword.

I've reverted the import statements from the services, but the commit that added this references imagemagick so I wanted to double check before removing this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes. I thought I had reverted that change.


# ======== #
# SECURITY #
# ======== #
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ GEM
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
arel (>= 9.0)
activerecord-import (1.0.5)
activerecord (>= 3.2)
activestorage (5.2.4.3)
actionpack (= 5.2.4.3)
activerecord (= 5.2.4.3)
Expand Down Expand Up @@ -484,6 +486,7 @@ PLATFORMS
ruby

DEPENDENCIES
activerecord-import
annotate
annotate_gem
api-pagination
Expand Down
14 changes: 8 additions & 6 deletions app/controllers/org_admin/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ def show
section: { phase: :template })
.find(params[:id])
authorize question
render partial: "show", locals: {
render json: { html: render_to_string(partial: "show", locals: {
template: question.section.phase.template,
section: question.section,
question: question,
conditions: question.conditions
}
})}
end

def open_conditions
Expand All @@ -37,19 +37,21 @@ def open_conditions
webhooks: webhook_hash(question.conditions) }
end


# GET /org_admin/templates/[:template_id]/phases/[:phase_id]/sections/[:id]/questions/[:question_id]/edit
def edit
question = Question.includes(:annotations,
:question_options,
section: { phase: :template })
.find(params[:id])
authorize question
render partial: "edit", locals: {
render json: { html: render_to_string(partial: "edit", locals: {
template: question.section.phase.template,
section: question.section,
question: question,
question_formats: allowed_question_formats,
conditions: question.conditions
}
})}
end

def new
Expand All @@ -61,7 +63,7 @@ def new
number: nbr.present? ? nbr + 1 : 1)
question_formats = allowed_question_formats
authorize question
render partial: "form", locals: {
render json: { html: render_to_string(partial: "form", locals: {
template: section.phase.template,
section: section,
question: question,
Expand All @@ -71,7 +73,7 @@ def new
phase_id: section.phase.id,
id: section.id),
question_formats: question_formats
}
}) }
end

def create
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/org_admin/sections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def edit
else
"show"
end
render partial: partial_name,
render json: { html: render_to_string(partial: partial_name,
locals: {
template: section.phase.template,
phase: section.phase,
section: section
}
})}
end

# POST /org_admin/templates/[:template_id]/phases/[:phase_id]/sections
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/src/orgAdmin/conditions/updateConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,27 @@ export default function updateConditions(id) {
}
};

// display conditions (editing) upon click of 'Add Logic'
parent.on('ajax:success', 'a.add-logic[data-remote="true"]', (e, data) => {
// display conditions (editing) upon click of 'Add Conditions'
parent.on('ajax:success', 'a.add-logic[data-remote="true"]', (e) => {
addLogicButton.attr('data-loaded', 'true');
addLogicButton.addClass('disabled');
addLogicButton.blur();
addLogicButton.text('Conditions');
if (isObject(content)) {
content.html(data.container);
content.html(e.detail[0].container);
}
setSelectPicker();
webhookForm(data.webhooks, undefined);
webhookForm(e.detail[0].webhooks, undefined);
});

// add condition
parent.on('ajax:success', 'a.add-condition[data-remote="true"]', (e, data) => {
parent.on('ajax:success', 'a.add-condition[data-remote="true"]', (e) => {
const conditionList = $(e.target).closest('#condition-container').find('.condition-list');
const addDiv = $(e.target).closest('#condition-container').find('.add-condition-div');
if (isObject(conditionList)) {
conditionList.attr('data-loaded', 'true');
conditionList.append(data.attachment_partial);
addDiv.html(data.add_link);
conditionList.append(e.detail[0].attachment_partial);
addDiv.html(e.detail[0].add_link);
conditionList.attr('data-loaded', 'false');
setSelectPicker();
const selectObject = conditionList.find('.selectpicker.action-type').last();
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/src/orgAdmin/phases/newEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ $(() => {
return panelBody.attr('data-loaded') === 'false';
});

$(parentSelector).on('ajax:success', 'a.ajaxified-section[data-remote="true"]', (e, data) => {
$(parentSelector).on('ajax:success', 'a.ajaxified-section[data-remote="true"]', (e) => {
const panelBody = $(e.target).parent().find('.panel-body');
const panel = panelBody.parent();
if (isObject(panelBody)) {
// Display the section's html
panelBody.attr('data-loaded', 'true');
panelBody.html(data);
panelBody.html(e.detail[0].html);
// Wire up the section
initSection(`#${panel.attr('id')}`);
}
Expand All @@ -123,13 +123,13 @@ $(() => {
});
}
});
$(parentSelector).on('ajax:success', 'a.ajaxified-question[data-remote="true"]', (e, data) => {
$(parentSelector).on('ajax:success', 'a.ajaxified-question[data-remote="true"]', (e) => {
const target = $(e.target);
const panelBody = getQuestionPanel(target);
if (isObject(panelBody)) {
const id = panelBody.attr('id');
// Display the section's html
panelBody.html(data);
panelBody.html(e.detail[0].html);
initQuestion(id);
updateConditions(id);
if (panelBody.is('.new-question')) {
Expand Down
19 changes: 10 additions & 9 deletions app/services/org/create_created_plan_service.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors due to threading
import OrgDateRangeable
import StatCreatedPlan
import StatCreatedPlan::CreateOrUpdate
import Role
import User
import Plan
import Perm
import Template
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatCreatedPlan.class
StatCreatedPlan::CreateOrUpdate.class
Role.class
User.class
Plan.class
Perm.class
Template.class

class Org

Expand Down
17 changes: 9 additions & 8 deletions app/services/org/create_exported_plan_service.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors
import OrgDateRangeable
import StatExportedPlan
import StatExportedPlan::CreateOrUpdate
import Role
import Plan
import User
import ExportedPlan
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatExportedPlan.class
StatExportedPlan::CreateOrUpdate.class
Role.class
Plan.class
User.class
ExportedPlan.class

class Org

Expand Down
11 changes: 6 additions & 5 deletions app/services/org/create_joined_user_service.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors due to threading
import OrgDateRangeable
import StatJoinedUser
import StatJoinedUser::CreateOrUpdate
import User
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatJoinedUser.class
StatJoinedUser::CreateOrUpdate.class
User.class

class Org

Expand Down
19 changes: 10 additions & 9 deletions app/services/org/create_last_month_created_plan_service.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors due to threading
import OrgDateRangeable
import StatCreatedPlan
import StatCreatedPlan::CreateOrUpdate
import Role
import User
import Plan
import Perm
import Template
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatCreatedPlan.class
StatCreatedPlan::CreateOrUpdate.class
Role.class
User.class
Plan.class
Perm.class
Template.class


class Org
Expand Down
17 changes: 9 additions & 8 deletions app/services/org/create_last_month_exported_plan_service.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors
import OrgDateRangeable
import StatExportedPlan
import StatExportedPlan::CreateOrUpdate
import Role
import Plan
import User
import ExportedPlan
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatExportedPlan.class
StatExportedPlan::CreateOrUpdate.class
Role.class
Plan.class
User.class
ExportedPlan.class

class Org

Expand Down
11 changes: 6 additions & 5 deletions app/services/org/create_last_month_joined_user_service.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors due to threading
import OrgDateRangeable
import StatJoinedUser
import StatJoinedUser::CreateOrUpdate
import User
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatJoinedUser.class
StatJoinedUser::CreateOrUpdate.class
User.class

class Org

Expand Down
15 changes: 8 additions & 7 deletions app/services/org/create_last_month_shared_plan_service.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors due to threading
import OrgDateRangeable
import StatSharedPlan
import StatSharedPlan::CreateOrUpdate
import User
import Plan
import Role
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatSharedPlan.class
StatSharedPlan::CreateOrUpdate.class
User.class
Plan.class
Role.class

class Org

Expand Down
15 changes: 8 additions & 7 deletions app/services/org/create_shared_plan_service.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

#import statements fix Circular dependancy errors due to threading
import OrgDateRangeable
import StatSharedPlan
import StatSharedPlan::CreateOrUpdate
import User
import Plan
import Role
# statements fix Circular dependancy errors due to threading
# see: https://github.com/grosser/parallel#nameerror-uninitialized-constant
OrgDateRangeable.class
StatSharedPlan.class
StatSharedPlan::CreateOrUpdate.class
User.class
Plan.class
Role.class

class Org

Expand Down