Support balances and add warnings #483
Conversation
app/models/balance.rb
Outdated
@@ -0,0 +1,87 @@ | |||
# This describes disk quota utilization for a given user and volume |
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.
Update comment to describe balance instead of disk quota. Maybe in parentheses (RUs) in comments for us on Gateways?
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 would prefer that the comment refer to config.unit
specifically, and call out resource units as what are used at OSC.
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.
Shouldn't that go in README or does it belong in model header too?
app/models/balance.rb
Outdated
|
||
def balance_object | ||
return @project if @project.present? | ||
@user |
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.
Can use the new presence here:
def balance_object
project.presence || user
end
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.
Change made.
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 would prefer that we be explicit that config.unit
can be any string value that makes sense for a given site, but I won't make that a hard requirement.
Looks good!
app/models/balance.rb
Outdated
@@ -0,0 +1,87 @@ | |||
# This describes disk quota utilization for a given user and volume |
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 would prefer that the comment refer to config.unit
specifically, and call out resource units as what are used at OSC.
Turns out updating every 15 minutes is useless because OSC only sends charging data to database once a day, which seems logical other sites do things similarly as easier to charge for previous day than several times a day. Going to remove the refresh locale. |
Actually might leave text but modify for default to daily. |
One thing I added and can revert if not wanted is concept of OnDemand having timezone configured. The ActiveSupport time zone names I couldn't get from local server timezone via |
We should actually revert the timezone change. In the Job Composer we use this Rails gem https://github.com/basecamp/local_time. That adds a view helper "local_time" so you can do something like this:
The result is the user sees something in their own time zone instead of UTC time formatted string. Thus, if I create a new job at Utah's CHPC or at OSC in the Job Composer the created at displays like this: "September 6, 2019 2:35pm" - even though the time zones are different I know as a user I created both of those 15 minutes ago since it is 2:50 PM right now. If you want to display this string in local time that would be the most appropriate to do now. As far as having an OOD_TIMEZONE, you could open a separate issue on the ondemand repo about the topic of displaying time in OnDemand and we could adopt a more formalized strategy that addresses drawbacks or insufficiency of using Basecamp's local_time gem. |
Added commit that uses |
@@ -2,7 +2,7 @@ | |||
<%= t('dashboard.balance_warning_prefix_html', units_balance: balance.units_balance, unit: @unit) %> | |||
<strong><%= balance.project_type %> <%= balance.balance_object %></strong> | |||
<small class="pull-right hidden-xs hidden-sm"> | |||
<%= t('dashboard.balance_reload_message_html', last_update: balance.last_update) %> | |||
<%= t('dashboard.balance_reload_message_html', last_update: local_time(balance.last_update)) %> |
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.
This could just be:
<%= t('dashboard.balance_reload_message_html', last_update: local_time(balance.updated_at)) %>
and Balance#last_update
removed as Balance#last_update
purpose is to make a local time human readable form of Balance#updated_at
, which is what local_time(balance.updated_at)
also achieves.
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.
Change made, put format into view. I wasn't able to get newer local_time gem to work with internationalization so left hardcoded format in view.
@@ -0,0 +1,12 @@ | |||
<h4> | |||
<%= t('dashboard.balance_warning_prefix_html', units_balance: balance.units_balance, unit: @unit) %> |
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.
@unit
is an instance variable of Balance
so should this instead be:
<%= t('dashboard.balance_warning_prefix_html', units_balance: balance.units_balance, unit: balance.unit) %>
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.
Fixed
</h4> | ||
<ul class="list-unstyled"> | ||
<li> | ||
<%= balance.to_s %>. <%= t('dashboard.balance_additional_message', balanace_units: balance.balanace_units, unit: @unit) %> |
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.
See comment above, it seems like @unit
here should actually be balance.unit
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.
Fixed
Screenshot using default locales
Screenshot using OSC locales