<commit_before>var Backbone = require('backbone');
var moment = require('moment');


var adminui = require('../adminui');
var Jobs = require('../models/jobs');

var JobProgressView = require('./job-progress');
var JobDetailsView = require('./job');

var JobsItemViewTemplate = require('../tpl/jobs-item.hbs');
var JobsItemView = Backbone.Marionette.ItemView.extend({
    template: JobsItemViewTemplate,
    tagName: 'tr',
    events: {
        "click a.name": "showJobDetails"
    },
    initialize: function(options) {
        options.showDetailsInModal = options.showdetailsInModal || false;

        if (options.showDetailsInModal) {
            this.detailsView = JobProgressView;
        } else {
            this.detailsView = JobDetailsView;
        }
    },
    serializeData: function() {
        var data = Backbone.Marionette.ItemView.prototype.serializeData.call(this, arguments);
        if (! data.params) {
            return {};
        }

        if (data.created_at) {
            data.when = moment(data.created_at).utc().format('lll');
        } else {
            data.when = 'unknown';
        }
        // console.log(this.model);
        data.duration = this.model.duration();

        if (data.name.indexOf('update') !== -1 && data.params) {

            var summary = [];
            if (data.params.new_owner_uuid) {
                summary.push('change owner');
            }

            if (data.params.package_name) {
                summary.push('resize');
            }

            if (data.params.alias) {
                summary.push('rename');
            }
            data.summary = summary.join(' + ');
        }<commit_msg>ADMINUI-1617 jobs list duration display in seconds should be rounded<commit_after>var Backbone = require('backbone');
var moment = require('moment');


var adminui = require('../adminui');
var Jobs = require('../models/jobs');

var JobProgressView = require('./job-progress');
var JobDetailsView = require('./job');

var JobsItemViewTemplate = require('../tpl/jobs-item.hbs');

var JobsItemView = Backbone.Marionette.ItemView.extend({
    template: JobsItemViewTemplate,
    tagName: 'tr',
    events: {
        "click a.name": "showJobDetails"
    },
    initialize: function(options) {
        options.showDetailsInModal = options.showdetailsInModal || false;

        if (options.showDetailsInModal) {
            this.detailsView = JobProgressView;
        } else {
            this.detailsView = JobDetailsView;
        }
    },
    serializeData: function() {
        var data = Backbone.Marionette.ItemView.prototype.serializeData.call(this, arguments);
        if (! data.params) {
            return {};
        }

        if (data.created_at) {
            data.when = moment(data.created_at).utc().format('lll');
        } else {
            data.when = 'unknown';
        }
        // console.log(this.model);
        data.duration = parseFloat(Math.round(this.model.duration() * 100) / 100).toFixed(2);


        if (data.name.indexOf('update') !== -1 && data.params) {

            var summary = [];
            if (data.params.new_owner_uuid) {
                summary.push('change owner');
            }

            if (data.params.package_name) {
                summary.push('resize');
            }

            if (data.params.alias) {
                summary.push('rename');
            }
            data.summary = summary.join(' + ');
        }
{'fraction_non_alphanumeric': 0.14248251748251747, 'fraction_numerical': 0.003787878787878788, 'mean_word_length': 2.054270462633452, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3923488', 'n_tokens_mistral': 993, 'n_tokens_neox': 952, 'n_words': 173}