X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/19d0b4c509ec720f9ffc1ea13f758c5825308834..bfd5100c4e0bed1910875099937169f1b0c8ce7b:/apps/workbench/app/assets/javascripts/keep_disks.js.coffee diff --git a/apps/workbench/app/assets/javascripts/keep_disks.js.coffee b/apps/workbench/app/assets/javascripts/keep_disks.js.coffee index 761567942f..e4aa4b4321 100644 --- a/apps/workbench/app/assets/javascripts/keep_disks.js.coffee +++ b/apps/workbench/app/assets/javascripts/keep_disks.js.coffee @@ -1,3 +1,28 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ +cache_age_in_days = (milliseconds_age) -> + ONE_DAY = 1000 * 60 * 60 * 24 + milliseconds_age / ONE_DAY + +cache_age_hover = (milliseconds_age) -> + 'Cache age ' + cache_age_in_days(milliseconds_age).toFixed(1) + ' days.' + +cache_age_axis_label = (milliseconds_age) -> + cache_age_in_days(milliseconds_age).toFixed(0) + ' days' + +float_as_percentage = (proportion) -> + (proportion.toFixed(4) * 100) + '%' + +$.renderHistogram = (histogram_data) -> + Morris.Area({ + element: 'cache-age-vs-disk-histogram', + pointSize: 0, + lineWidth: 0, + data: histogram_data, + xkey: 'age', + ykeys: ['persisted', 'cache'], + labels: ['Persisted Storage Disk Utilization', 'Cached Storage Disk Utilization'], + ymax: 1, + ymin: 0, + xLabelFormat: cache_age_axis_label, + yLabelFormat: float_as_percentage, + dateFormat: cache_age_hover + })