<commit_before>// -*- coding: utf-8 -*-
// (c) 2013,2014 <NAME>, Elmyra UG

OpsPublishedDataSearch = Backbone.Model.extend({
    url: '/api/ops/published-data/search',
    keywords: [],
    perform: function(documents, metadata, query, range) {

        indicate_activity(true);

        documents.reset();
        //$('.pager-area').hide();
        $(opsChooserApp.paginationViewBottom.el).hide();

        var self = this;
        return this.fetch({
            data: $.param({ query: query, range: range}),
            success: function (payload, response, options) {

                self.keywords = jQuery.parseJSON(options.xhr.getResponseHeader('X-Elmyra-Query-Keywords'));

                indicate_activity(false);
                $('#alert-area').empty();
                $('.pager-area').show();

                //console.log("payload raw:");
                //console.log(payload);
                console.log("payload data:");
                console.log(payload['attributes']);

                if (_.isEmpty(payload['attributes'])) return;

                // get "node" containing record list from nested json response
                var search_result = payload['attributes']['ops:world-patent-data']['ops:biblio-search']['ops:search-result'];

                // unwrap response by creating a list of model objects from records
                var entries;
                if (search_result) {
                    $(opsChooserApp.paginationViewBottom.el).show();
                    var exchange_documents = to_list(search_result['exchange-documents']);
                    entries = _.map(exchange_documents, function(entry) { return new OpsExchangeDocument(entry['exchange-document']); });
                }

                // propagate data to model collection instance
                documents.reset(entries);

                // propagate metadata to model
                var biblio_search = payload['attributes']['ops:world-patent-data']['ops:biblio-search'];
                var result_count = biblio_search['@total-result-count'];
                var result_range_node = biblio_search['ops:range'];
                var result_range = result_range_node['@begin'] + '-' + result_range_node['@end'];
                var query_real = biblio_search['ops:query']['$'];
                metadata.set({result_count: result_count, result_range: result_range, query_real: query_real});
                metadata.set('keywords', _.union(self.keywords, metadata.get('keywords')));

            },
            error: function(e, xhr) {

                //console.log("error: " + xhr.responseText);

                indicate_activity(false);
                reset_content();

                response = jQuery.parseJSON(xhr.responseText);
                if (response['status'] == 'error') {
                    _.each(response['errors'], function(error) {
                        var tpl = _.template($('#backend-error-template').html());
                        var alert_html = tpl(error);
                        $('#alert-area').append(alert_html);
                    });
                    $(".very-short").shorten({showChars: 0, moreText: 'more', lessText: 'less'});
                }
            }
        });

    },
});

OpsExchangeMetadata = Backbone.Model.extend({

    defaults: {
        page_size: 25,
        result_count: null,
        result_range: null,
        query_real: null,
        pagination_entry_count: 12,
        pagination_pagesize_choices: [25, 50, 75, 100],
        keywords: [],

        get_url: function() {
            var url =
                window.location.pathname +
                '?query=' + encodeURIComponent($('#query').val()) +
                '&pagesize=' + this.page_size;
            return url;
        },
        get_url_print: function() {
            return this.get_url() + '&print=true';
        },
        get_url_pdf: function() {
            return this.get_url() + '&pdf=true';<commit_msg>ui: add logging to OpsExchangeMetadata.get_url_pdf<commit_after>// -*- coding: utf-8 -*-
// (c) 2013,2014 <NAME>, Elmyra UG

OpsPublishedDataSearch = Backbone.Model.extend({
    url: '/api/ops/published-data/search',
    keywords: [],
    perform: function(documents, metadata, query, range) {

        indicate_activity(true);

        documents.reset();
        //$('.pager-area').hide();
        $(opsChooserApp.paginationViewBottom.el).hide();

        var self = this;
        return this.fetch({
            data: $.param({ query: query, range: range}),
            success: function (payload, response, options) {

                self.keywords = jQuery.parseJSON(options.xhr.getResponseHeader('X-Elmyra-Query-Keywords'));

                indicate_activity(false);
                $('#alert-area').empty();
                $('.pager-area').show();

                //console.log("payload raw:");
                //console.log(payload);
                console.log("payload data:");
                console.log(payload['attributes']);

                if (_.isEmpty(payload['attributes'])) return;

                // get "node" containing record list from nested json response
                var search_result = payload['attributes']['ops:world-patent-data']['ops:biblio-search']['ops:search-result'];

                // unwrap response by creating a list of model objects from records
                var entries;
                if (search_result) {
                    $(opsChooserApp.paginationViewBottom.el).show();
                    var exchange_documents = to_list(search_result['exchange-documents']);
                    entries = _.map(exchange_documents, function(entry) { return new OpsExchangeDocument(entry['exchange-document']); });
                }

                // propagate data to model collection instance
                documents.reset(entries);

                // propagate metadata to model
                var biblio_search = payload['attributes']['ops:world-patent-data']['ops:biblio-search'];
                var result_count = biblio_search['@total-result-count'];
                var result_range_node = biblio_search['ops:range'];
                var result_range = result_range_node['@begin'] + '-' + result_range_node['@end'];
                var query_real = biblio_search['ops:query']['$'];
                metadata.set({result_count: result_count, result_range: result_range, query_real: query_real});
                metadata.set('keywords', _.union(self.keywords, metadata.get('keywords')));

            },
            error: function(e, xhr) {

                //console.log("error: " + xhr.responseText);

                indicate_activity(false);
                reset_content();

                response = jQuery.parseJSON(xhr.responseText);
                if (response['status'] == 'error') {
                    _.each(response['errors'], function(error) {
                        var tpl = _.template($('#backend-error-template').html());
                        var alert_html = tpl(error);
                        $('#alert-area').append(alert_html);
                    });
                    $(".very-short").shorten({showChars: 0, moreText: 'more', lessText: 'less'});
                }
            }
        });

    },
});

OpsExchangeMetadata = Backbone.Model.extend({

    defaults: {
        page_size: 25,
        result_count: null,
        result_range: null,
        query_real: null,
        pagination_entry_count: 12,
        pagination_pagesize_choices: [25, 50, 75, 100],
        keywords: [],

        get_url: function() {
            var url =
                window.location.pathname +
                '?query=' + encodeURIComponent($('#query').val()) +
                '&pagesize=' + this.page_size;
            return url;
        },
        get_url_print: function() {
            return this.get_url() + '&print=true';
        },
        get_url_pdf: function() {
            var url = this.get_url() + '&pdf=true';
            console.log('OpsExchangeMetadata.get_url: ' + url);
            console.log('window.location.pathname: ' + window.location.pathname);
            return url;
{'fraction_non_alphanumeric': 0.13985756385068762, 'fraction_numerical': 0.005648330058939097, 'mean_word_length': 1.8709904829044766, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5326395', 'n_tokens_mistral': 2262, 'n_tokens_neox': 2059, 'n_words': 394}