Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Support balances and add warnings #483

Merged
merged 17 commits into from Sep 18, 2019
Merged

Support balances and add warnings #483

merged 17 commits into from Sep 18, 2019

Conversation

treydock
Copy link
Contributor

Screenshot using default locales

Screen Shot 2019-08-30 at 3 15 49 PM

Screenshot using OSC locales

Screen Shot 2019-08-30 at 3 13 36 PM

@@ -0,0 +1,87 @@
# This describes disk quota utilization for a given user and volume
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?


def balance_object
return @project if @project.present?
@user
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change made.

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Contributor

@MorganRodgers MorganRodgers left a 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!

README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,87 @@
# This describes disk quota utilization for a given user and volume
Copy link
Contributor

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.

@treydock
Copy link
Contributor Author

treydock commented Sep 3, 2019

I updated it so config key is optional and added better default locale text if no units are provided

Screen Shot 2019-09-03 at 1 54 26 PM

@treydock
Copy link
Contributor Author

treydock commented Sep 3, 2019

Slightly better:

Screen Shot 2019-09-03 at 2 01 25 PM

@treydock
Copy link
Contributor Author

treydock commented Sep 4, 2019

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.

@treydock
Copy link
Contributor Author

treydock commented Sep 4, 2019

Actually might leave text but modify for default to daily.

@treydock
Copy link
Contributor Author

treydock commented Sep 4, 2019

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 Time so had to configure the Rails app. I couldn't set time zone with initializer since has to be set in Application class. The absence of a timezone just sticks with UTC which is the default. Since the time used for things like balances is specific to where the server is deployed and not the user's timzone, I opted for server-side time zone configuration.

@treydock
Copy link
Contributor Author

treydock commented Sep 4, 2019

This is current look using OSC specific units and project type but default locales.

Screen Shot 2019-09-04 at 8 04 14 AM

@ericfranz ericfranz self-assigned this Sep 6, 2019
@ericfranz
Copy link
Contributor

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:

<%= local_time(workflow.created_at) %>

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.

@treydock
Copy link
Contributor Author

treydock commented Sep 8, 2019

Added commit that uses local_time to generate the last_update value.

@@ -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)) %>
Copy link
Contributor

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.

Copy link
Contributor Author

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) %>
Copy link
Contributor

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) %>

Copy link
Contributor Author

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) %>
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@ericfranz ericfranz merged commit 47cb7b3 into master Sep 18, 2019
@ericfranz ericfranz deleted the balances branch September 18, 2019 00:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants