<commit_before>/**
 * Created by i.navrotskyj on 01.03.2016.
 */
define(["app", "config"], function(app, config) {

    app.factory("CdrModel", ["webitel", "$localStorage", "notifi", "$q", function(webitel, $localStorage, notifi, $q) {

        var defaultMapColumn = [
            {
                "name": "created_time",
                "type": "timestamp",
                "caption": "Call start time"
            },
            {
                "name": "caller_id_number",
                "type": "string",
                "caption": "Caller number"
            },
            {
                "name": "caller_id_name",
                "type": "string",
                "caption": "Caller name"
            },
            {
                "name": "destination_number",
                "type": "string",
                "caption": "Destination number"
            },

            {
                "name": "billsec",
                "type": "integer",
                "caption": "Billsec"
            },
            {
                "name": "duration",
                "type": "integer",
                "caption": "Duration"
            },
            {
                "name": "direction",
                "type": "string",
                "caption": "Direction"
            },
            {
                "name": "hangup_cause",
                "type": "string",
                "caption": "Hangup cause"
            },
            {
                "name": "callflow.times.hangup_time",
                "type": "timestamp",
                "caption": "hangup_time"
            }
        ];

        var cacheColumn = null;

        function getDomainName() {
            return (webitel.connection.session.domain ?
                webitel.connection.session.domain : "root")
        }

        function setMetadataColumns(data, domain, cb) {
            webitel.api('POST', '/api/v2/metadata/cdr?domain=' + getDomainName(), JSON.stringify(data), cb)
        }

        function updateGridColumns(columns, cb) {
            setMetadataColumns(angular.copy(columns), getDomainName(), function (err, res) {
                if (err)
                    return notifi.error(err, 5000);

                var item = res && res.data;<commit_msg>set default cdr columns<commit_after>/**
 * Created by i.navrotskyj on 01.03.2016.
 */
define(["app", "config"], function(app, config) {

    app.factory("CdrModel", ["webitel", "$localStorage", "notifi", "$q", function(webitel, $localStorage, notifi, $q) {

        var defaultMapColumn = [
            {
                "name": "created_time",
                "type": "timestamp",
                "caption": "Call start time"
            },
            {
                "name": "direction",
                "type": "string",
                "caption": "Direction"
            },
            {
                "name": "caller_id_number",
                "type": "string",
                "caption": "Caller number"
            },
            {
                "name": "destination_number",
                "type": "string",
                "caption": "Destination number"
            },
            {
                "name": "extension",
                "type": "string",
                "caption": "Extension"
            },
            {
                "name": "duration",
                "type": "integer",
                "caption": "Duration"
            },
            {
                "name": "billsec",
                "type": "integer",
                "caption": "Bill, sec"
            },
            {
                "name": "hangup_cause",
                "type": "string",
                "caption": "Hangup cause"
            }
        ];

        var cacheColumn = null;

        function getDomainName() {
            return (webitel.connection.session.domain ?
                webitel.connection.session.domain : "root")
        }

        function setMetadataColumns(data, domain, cb) {
            webitel.api('POST', '/api/v2/metadata/cdr?domain=' + getDomainName(), JSON.stringify(data), cb)
        }

        function updateGridColumns(columns, cb) {
            setMetadataColumns(angular.copy(columns), getDomainName(), function (err, res) {
                if (err)
                    return notifi.error(err, 5000);

                var item = res && res.data;
{'fraction_non_alphanumeric': 0.13924050632911392, 'fraction_numerical': 0.005983889528193326, 'mean_word_length': 1.24831867563373, 'pattern_counts': {'":': 51, '<': 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': '7192298', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1102, 'n_words': 228}