jku-vds-lab / loops

Loops is a JupyterLab extension to support iterative and exploratory data analysis in computational notebooks.
https://jku-vds-lab.at/publications/2024_loops/
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Show state meta information #29

Closed keckelt closed 1 year ago

keckelt commented 1 year ago

Currently only the version is shown image

Show additional information like number of aggregated states, last execution, etc.

keckelt commented 1 year ago
/**
 * Translates seconds into human readable format of seconds, minutes, hours, days, and years
 * 
 * @param  {number} seconds The number of seconds to be processed
 * @return {string}         The phrase describing the amount of time
 */
function forHumans ( seconds ) {
    var levels = [
        [Math.floor(seconds / 31536000), 'years'],
        [Math.floor((seconds % 31536000) / 86400), 'days'],
        [Math.floor(((seconds % 31536000) % 86400) / 3600), 'hours'],
        [Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), 'minutes'],
        [(((seconds % 31536000) % 86400) % 3600) % 60, 'seconds'],
    ];
    var returntext = '';

    for (var i = 0, max = levels.length; i < max; i++) {
        if ( levels[i][0] === 0 ) continue;
        returntext += ' ' + levels[i][0] + ' ' + (levels[i][0] === 1 ? levels[i][1].substr(0, levels[i][1].length-1): levels[i][1]);
    };
    return returntext.trim();
}

https://stackoverflow.com/questions/8211744/convert-time-interval-given-in-seconds-into-more-human-readable-form

function formatTimeDuration(timestamp1, timestamp2) {
  const diffInSeconds = Math.abs(Math.floor((timestamp2 - timestamp1) / 1000));

  if (diffInSeconds < 60) {
    return diffInSeconds + ' seconds';
  } else if (diffInSeconds < 100 * 60) {
    const diffInMinutes = Math.floor(diffInSeconds / 60);
    return diffInMinutes + ' minutes';
  } else if (diffInSeconds < 24 * 3600) {
    const diffInHours = Math.floor(diffInSeconds / 3600);
    return diffInHours + ' hours';
  } else {
    const diffInDays = Math.floor(diffInSeconds / (24 * 3600));
    return diffInDays + ' days';
  }
}

https://chat.openai.com/share/97eebe66-3856-4ec7-957e-bb94bdeac347

keckelt commented 1 year ago

now using Github's relative time element