-
Notifications
You must be signed in to change notification settings - Fork 898
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
Do not delete report if task associated with this report deleted #15134
Do not delete report if task associated with this report deleted #15134
Conversation
79ce384
to
fd9a6b7
Compare
fd9a6b7
to
0945005
Compare
@gtanzillo rebased and ready for the second review |
0945005
to
d692cb1
Compare
app/models/miq_report_result.rb
Outdated
@@ -32,11 +30,16 @@ def result_set | |||
end | |||
|
|||
def status | |||
MiqTask.human_status(state_or_status) | |||
task = MiqTask.find_by(:id=>miq_task_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to reference the association miq_task
here instead of doing MiqTask.find_by(:id=>miq_task_id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gtanzillo right, no need for find_by
, changed
d692cb1
to
ef6922c
Compare
This pull request is not mergeable. Please rebase and repush. |
ef6922c
to
063e202
Compare
app/models/miq_report_result.rb
Outdated
@@ -36,7 +36,7 @@ def status | |||
end | |||
|
|||
def status_message | |||
miq_task.nil? ? _("Report results are no longer available") : miq_task.message | |||
miq_task.nil? ? _("Task associated with this report no longer available") : miq_task.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is logged or in the UI so, maybe The task associated with this report is no longer available"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
@@ -125,6 +125,33 @@ | |||
end | |||
end | |||
|
|||
describe "#state" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tests here are testing #status
, not #state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my mistake
@@ -11,10 +11,8 @@ class MiqReportResult < ApplicationRecord | |||
serialize :report | |||
|
|||
virtual_delegate :description, :to => :miq_group, :prefix => true, :allow_nil => true | |||
virtual_delegate :state_or_status, :to => "miq_task", :allow_nil => true | |||
virtual_attribute :status, :string, :uses => :state_or_status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell, is this required for this PR? How do you know it's unused? Can you locate the last caller or why it's unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search for string state_or_status
across all projects: found only in MiqTask
and it is not invocation of MiqTaskResult.state_or_status
@yrudman your commit message first line (subject) are too long: Try to keep them under 70 characters |
Are you comfortable squashing commits? The second and fourth commit are related in that the fourth undoes the way the second commit works and does it differently. They should probably be squashed since the first commit doesn't really stand on it's own anymore. |
063e202
to
246f6a6
Compare
@jrafanie yes, separate commits looks confusing, rebased to 1 commit... |
expect(miq_report_result.status).to eq "Running" | ||
end | ||
|
||
it "returns 'Complete' if report generated and associated task exists" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's two spaces after report here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor nitpick. I don't understand the use case of deleting tasks so I'm not sure what's expected, but this definitely solves the BZ.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1450272 Changes: - removed :dependent => :destroy on miq_report_result association in MiqTask - refactor MiqReportResult#status to return 'Complete' if task asociated with report deleted - added test coverage for MiqReportResult#status - remove not used virtual_delegate to MiqTask#state_or_status
246f6a6
to
fa4ebc6
Compare
Checked commit yrudman@fa4ebc6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@gtanzillo please review #15134 (review)... I'm good with the change but don't understand the use case of deleting tasks to know what the expected behavior is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this change. 👍 Thanks for reviewing @jrafanie
…deleted Do not delete report if task associated with this report deleted (cherry picked from commit c17d043) https://bugzilla.redhat.com/show_bug.cgi?id=1460394
Fine backport details:
|
Issue: Deleting task (in task management screen) also deleting report linked to that task
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1450272
Fixes:
:dependent => :destroy
on association betweenMiqTask
andMiqReportResult
MiqReportResult#status
now returnsCompleted
if associated task deletedAFTER: on screenshot first report has task associated with it and for last 2 reports (one successful and one failed) associated task was deleted
@miq-bot add-label core, bug