<commit_before>define(['backbone', '../models/dataset/connection'],
        function(Backbone, Connection) {
    'use strict';

    var ConnectionPool = Backbone.Collection.extend({

        model: Connection,

        initialize: function(models, options) {
            this.dataset = options['dataset'];
            this.defaultCut = options['defaultCut'];
        },

        getConnection: function(opts) {
            var id = this.getConnectionId(opts),
                conn = this.get(id);

            if (_.isUndefined(conn)) {
                var defaults = {
                    id: id,
                    dataset: this.dataset,
                    cut: this.defaultCut
                };
                conn = new Connection(_.extend(defaults, opts));
                this.add(conn);
            }

            return conn;
        },

        getConnectionId: function(opts) {
            switch(opts['type']) {
                case 'dimensions':
                    return opts['type'] + ':' + opts['dimension'];

                case 'observations':
                    return opts['type'] + ':' + opts['dimension'] + ':' + opts['measure'];<commit_msg>Use aggregation to namespace the connection id<commit_after>define(['backbone', '../models/dataset/connection'],
        function(Backbone, Connection) {
    'use strict';

    var ConnectionPool = Backbone.Collection.extend({

        model: Connection,

        initialize: function(models, options) {
            this.dataset = options['dataset'];
            this.defaultCut = options['defaultCut'];
        },

        getConnection: function(opts) {
            var id = this.getConnectionId(opts),
                conn = this.get(id);

            if (_.isUndefined(conn)) {
                var defaults = {
                    id: id,
                    dataset: this.dataset,
                    cut: this.defaultCut
                };
                conn = new Connection(_.extend(defaults, opts));
                this.add(conn);
            }

            return conn;
        },

        getConnectionId: function(opts) {
            switch(opts['type']) {
                case 'dimensions':
                    return opts['type'] + ':' + opts['dimension'];

                case 'observations':
                    return opts['type'] + ':' + opts['dimension'] + ':' + opts['measure'] + ':' + opts['aggregation'];
{'fraction_non_alphanumeric': 0.13130471029595664, 'fraction_numerical': 0.0, 'mean_word_length': 1.5450689289501591, 'pattern_counts': {'":': 0, '<': 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': '634239', 'n_tokens_mistral': 605, 'n_tokens_neox': 559, 'n_words': 118}