-
Notifications
You must be signed in to change notification settings - Fork 356
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
Fixed correct setting of record to get counts of relationships #5995
Fixed correct setting of record to get counts of relationships #5995
Conversation
@h-kataria We should not be calling the CloudTenant But also, looks like in EmsDashboardService, (Also, Maybe the real problem is that CloudTenantDashboardService should not inherit from EmsDashboardService but only share a DashboardService or a mixin that doesn't assume the record is an ems? Or can we just get rid of the |
@himdel i agree with you, CloudTenant Dashboard should not be using the shared code with EmsDashboardService. Let me try to fix that, since these BZs need to be backported i was trying to keep changes to minimum. |
Aah, |
5653565
to
92adb18
Compare
- Fixed to CloudTenantService to not inherit from EmsDashboardService, instead inherit from DashboardService and have it's own methods so correct data can be fetched using CloudTenant record. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1731735 Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1487178
92adb18
to
6440497
Compare
@himdel please re-review |
to_char_args = [db_table[:created_on], Arel::Nodes::SqlLiteral.new("'YYYY-MM-DD'")] | ||
group_by_sql = Arel::Nodes::NamedFunction.new("to_char", to_char_args) | ||
|
||
model.where(:ems_id => @record.ext_management_system.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.
I wonder if this is right after all.
I mean, we're showing a list of vms or images whcih have the same ems as the cloud tenant.
This is definitely better than before, where we would show vms and images of a random EMS (that happened to have the same db id as the cloud tenant).
But.. don't we have a ..more directl link between cloud tenant and instances/images?
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.
... we do, @record.vms
and @record.miq_templates
.
So, what about adding a relation
argument to recent_records
and recent_resources
and doing..
def recent_records(model, relation)
db_table = model.arel_table
to_char_args = [db_table[:created_on], Arel::Nodes::SqlLiteral.new("'YYYY-MM-DD'")]
group_by_sql = Arel::Nodes::NamedFunction.new("to_char", to_char_args)
relation.where(db_table[:created_on].gt(30.days.ago.utc))
.group(group_by_sql.to_sql)
.count
end
def recent_images_data
recent_resources(MiqTemplate, _('Recent Images'), _('Images'), @record.miq_templates)
end
def recent_instances_data
recent_resources(ManageIQ::Providers::CloudManager::Vm, _('Recent Instances'), _('Instances'), @record.vms)
end
LGTM, thanks for splitting this! :) Just that cloud_tenant.vms vs all vms under cloud_tenant.ext_management_system difference :) |
@himdel thx for the suggestion on passing the relation, implemented that, it works better now. |
79454b5
to
28427c4
Compare
Passing in a relation to `recent_records` to get recent vms/templates for the selected CloudTenant record Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1731735 Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1487178
28427c4
to
1371c00
Compare
Checked commits h-kataria/manageiq-ui-classic@6440497~...1371c00 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
LGTM, seeing consistent counts in the dashboard and the list screen :) |
…view Fixed correct setting of record to get counts of relationships (cherry picked from commit 1492f6a) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1731735 Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1487178
Ivanchuk backport details:
|
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1731735
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1487178
before
![Screenshot from 2019-08-12 13-45-00](https://user-images.githubusercontent.com/3450808/62890058-a3fe7700-bd10-11e9-8e33-eceab0bdab7c.png)
after
![Screenshot from 2019-08-12 13-54-53](https://user-images.githubusercontent.com/3450808/62890065-a791fe00-bd10-11e9-9013-4e02922dbf45.png)