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

Remove old methods for loading virtual columns #11791

Merged

Conversation

lpichler
Copy link
Contributor

we are loading virtual custom columns from MiqExpression
when MiqExpression object is created #11369

so don't need to load it in when report is generated.

@miq-bot add_label reporting, technical-debt

@miq-bot
Copy link
Member

miq-bot commented Oct 10, 2016

@lpichler Cannot apply the following label because they are not recognized: technical-debt

@Fryguy Fryguy merged commit 5682546 into ManageIQ:master Oct 10, 2016
@Fryguy Fryguy added this to the Sprint 48 Ending Oct 24, 2016 milestone Oct 10, 2016
@chessbyte
Copy link
Member

Euwe Backport conflict:

$ git cherry-pick -e -x -m 1  5682546 
error: could not apply 5682546... Merge pull request #11791 from lpichler/remove_old_methods_for_loading_virtual_columns
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

$ git status
On branch euwe
Your branch is up-to-date with 'upstream/euwe'.
You are currently cherry-picking commit 5682546.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:

    modified:   app/models/miq_report.rb
    modified:   spec/models/miq_report_spec.rb

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   lib/miq_expression.rb

$ git diff
diff --cc lib/miq_expression.rb
index ab5ed6e,d74574c..0000000
--- a/lib/miq_expression.rb
+++ b/lib/miq_expression.rb
@@@ -1540,25 -1553,35 +1540,55 @@@ class MiqExpressio
      end
    end

++<<<<<<< HEAD
 +  def custom_attribute_columns(expression = nil)
 +    return custom_attribute_columns(exp).uniq if expression.nil?
 +
 +    case expression
 +    when Array
 +      expression.flat_map { |x| custom_attribute_columns(x) }
 +    when Hash
 +      expression_values = expression.values
 +
 +      if expression.keys.first == "field"
 +        field = Field.parse(expression_values.first)
 +        field.custom_attribute_column? ? [field.column] : []
 +      else
 +        expression.keys.first.casecmp('find').zero? ? [] : custom_attribute_columns(expression_values)
++=======
+   def custom_attribute_columns_and_models(expression = nil)
+     return custom_attribute_columns_and_models(exp).uniq if expression.nil?
+ 
+     case expression
+     when Array
+       expression.flat_map { |x| custom_attribute_columns_and_models(x) }
+     when Hash
+       expression_values = expression.values
+       return [] unless expression.keys.first
+ 
+       if expression.keys.first == "field"
+         begin
+           field = Field.parse(expression_values.first)
+         rescue StandardError => err
+           _log.error("Cannot parse field #{field}" + err.message)
+           _log.log_backtrace(err)
+         end
+ 
+         return [] unless field
+ 
+         field.custom_attribute_column? ? [:model => field.model, :column => field.column] : []
+       else
+         expression.keys.first.casecmp('find').try(:zero?) ? [] : custom_attribute_columns_and_models(expression_values)
++>>>>>>> 5682546... Merge pull request #11791 from lpichler/remove_old_methods_for_loading_virtual_columns
        end
      else
        []
      end
    end
++<<<<<<< HEAD
++=======
+ 
++>>>>>>> 5682546... Merge pull request #11791 from lpichler/remove_old_methods_for_loading_virtual_columns

    private

@chessbyte
Copy link
Member

@lpichler Please make an Euwe-specific PR resolving the cherry-pick conflict above or specify another PR that needs to be backported.
/cc @gtanzillo @Fryguy

chessbyte pushed a commit that referenced this pull request Oct 14, 2016
…g_virtual_columns

Remove old methods for loading virtual columns
(cherry picked from commit 5682546)
@chessbyte
Copy link
Member

Since #11369 has been backported to Euwe, this now cherry-picks cleanly.
Euwe Backport details:

$ git log -1
commit e72dd31de033b77a6cc51c8537766f8656306f3a
Author: Jason Frey <fryguy9@gmail.com>
Date:   Mon Oct 10 18:23:55 2016 -0400

    Merge pull request #11791 from lpichler/remove_old_methods_for_loading_virtual_columns

    Remove old methods for loading virtual columns
    (cherry picked from commit 5682546c8658d1d084e8b576be16faa9fe4871ac)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants