<commit_before>/*
 * Copyright (c) $year, <NAME> (DNT)
 *
 * https://github.com/Turistforeningen/turadmin
 */

var DNT = window.DNT || {};

(function (ns) {
    "use strict";

    ns.IndexView = Backbone.View.extend({

        el: '#listContainer',
        isLoading: true,

        initialize : function (options) {
            var mergedUserData = options.userData || {};
            mergedUserData.grupper = options.userGroups;
            var user = new ns.User(mergedUserData);
            this.user = user;

            this.collection = new ns.RouteCollection();
            this.collection.on('reset', this.onRoutesFetched, this);

            var provider = user.get('provider'),
                groups = user.get('grupper') || [],
                group;

            if (provider == 'DNT Connect' && groups.length) {
                this.groups = groups;
                this.fetchQuery = options.userDefaultRouteFetchQuery || {'privat.opprettet_av.id': user.get('id')}; // {'gruppe': _.first(groups).object_id}

            } else if (provider == 'Innholdspartner') {
                this.fetchQuery = {'gruppe': user.get('gruppe')._id};

            } else {
                this.fetchQuery = {'privat.opprettet_av.id': user.get('id')};
            }

            this.fetchRoutes();
            this.render();<commit_msg>Only set fetch query for group user if gruppe._id is set.<commit_after>/*
 * Copyright (c) $year, <NAME> (DNT)
 *
 * https://github.com/Turistforeningen/turadmin
 */

var DNT = window.DNT || {};

(function (ns) {
    "use strict";

    ns.IndexView = Backbone.View.extend({

        el: '#listContainer',
        isLoading: true,

        initialize : function (options) {
            var mergedUserData = options.userData || {};
            mergedUserData.grupper = options.userGroups;
            var user = new ns.User(mergedUserData);
            this.user = user;

            this.collection = new ns.RouteCollection();
            this.collection.on('reset', this.onRoutesFetched, this);

            var provider = user.get('provider'),
                groups = user.get('grupper') || [],
                group;

            if (provider == 'DNT Connect' && groups.length) {
                this.groups = groups;
                this.fetchQuery = options.userDefaultRouteFetchQuery || {'privat.opprettet_av.id': user.get('id')}; // {'gruppe': _.first(groups).object_id}

            } else if (provider == 'Innholdspartner') {
                group = user.get('gruppe');
                this.fetchQuery = (!!group && !!group._id) ? {gruppe: group._id} : {};

            } else {
                this.fetchQuery = {'privat.opprettet_av.id': user.get('id')};
            }

            this.fetchRoutes();
            this.render();
{'fraction_non_alphanumeric': 0.14893617021276595, 'fraction_numerical': 0.0, 'mean_word_length': 1.9542066027689031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6258169', 'n_tokens_mistral': 828, 'n_tokens_neox': 794, 'n_words': 157}