<commit_before>var Collection = require('ampersand-rest-collection');
var Connection = require('./extended-model');
var storageMixin = require('storage-mixin');
var each = require('lodash.foreach');
var electron = require('electron');
var electronApp = electron.remote ? electron.remote.app : undefined;
var raf = require('raf');

module.exports = Collection.extend(storageMixin, {
  model: Connection,
  namespace: 'Connections',
  storage: {
    backend: 'splice',
    appName: electronApp ? electronApp.getName() : undefined
  },
  comparator: function(a, b) {
    if (a.is_favorite === b.is_favorite) {
      return a.last_used - b.last_used;
    }
    return a.is_favorite ? -1 : 1;
  },
  mainIndex: '_id',<commit_msg>Conditionally get app name<commit_after>const Collection = require('ampersand-rest-collection');
const Connection = require('./extended-model');
const storageMixin = require('storage-mixin');
const each = require('lodash.foreach');
const raf = require('raf');

let appName;

try {
  const electron = require('electron');
  appName = electron.remote ? electron.remote.app : undefined;
} catch (e) {
  /* eslint no-console: 0 */
  console.log('Could not load electron', e.message);
}

module.exports = Collection.extend(storageMixin, {
  model: Connection,
  namespace: 'Connections',
  storage: {
    backend: 'splice',
    appName: appName
  },
  comparator: function(a, b) {
    if (a.is_favorite === b.is_favorite) {
      return a.last_used - b.last_used;
    }
    return a.is_favorite ? -1 : 1;
  },
  mainIndex: '_id',
{'fraction_non_alphanumeric': 0.14987080103359174, 'fraction_numerical': 0.003229974160206718, 'mean_word_length': 4.163333333333333, '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': '4199996', 'n_tokens_mistral': 500, 'n_tokens_neox': 492, 'n_words': 114}