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

Create report types #304

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions db/migrate/20181107164348_create_report_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateReportType < ActiveRecord::Migration[5.0]
def change
create_table :report_types do |t|
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure report_types is the best name here. Maybe reportable_fields?

This table will store one row per entry in https://github.com/lpichler/manageiq/blob/ce3bb5dc39eb168a70a9f6be73ed496cb5dc6c22/app/models/chargeback_vm.rb#L2 right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

first usage, is for ChargeableField. One row of ChargeableField could have 2 chargeback report types. For example, v_derived_cpu_total_cores_used belongs to ChargebackContainerImage, ChargebackContainerProject chargeback report types.

So firstly I was modeling:

ChargeableField has_many ChargebackReportType and then
I realized that probably it could be useful to don't limit ourselves and go with general way:

ChargeableField has_many ReportType

due this facts, I think that name reportable_fields doesn't explain the idea of intended report types. But as my native language is not english - I could be wrong :)

what do you think now?

thanks!

Copy link
Member

Choose a reason for hiding this comment

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

I'm still not sure what the resource is pointing to in that case? If its something inheriting from Chargeback then there won't be a database row, but if it's ChargeableField then why make it polymorphic?

t.string :name
t.belongs_to :resource, :polymorphic => true, :type => :bigint
t.timestamps
end

add_index :report_types, [:resource_id, :resource_type]
end
end