<commit_before>var App = Ember.Application.create();



// Models

App.Store = DS.Store.extend({
  revision: 13,
  adapter: EmberCouchDBKit.DocumentAdapter.create({db: 'boards'})
});

App.Issue = DS.Model.extend({
  text: DS.attr('string'),
  type: DS.attr('string', {defaultValue: 'issue'}),
  board: DS.attr('string')
});

App.Position = DS.Model.extend({
  issues: DS.hasMany('App.Issue', {embeded: true}),
  type: DS.attr('string', {defaultValue: 'position'})
});


App.Boards = ['common', 'intermediate', 'advanced'];



// Routes

App.IndexRoute = Ember.Route.extend({

  setupController: function(controller, model) {
    this._feed();
    //this._setupPosition();
    self = this;
    App.Boards.forEach(function(type) {
      controller = self.controllerFor(type);
      controller.addObserver('content', controller, function(){

      });
    });
  },

  renderTemplate: function() {
    this.render();
    this.render('board',{outlet: 'common', into: 'index', controller: 'common'});
    this.render('board',{outlet: 'intermediate', into: 'index', controller: 'intermediate'});
    this.render('board',{outlet: 'advanced', into: 'index', controller: 'advanced'});
  },

  _setupPosition: function() {
    App.Boards.forEach(function(type) {
      doc = App.Position.find(type);
      if (!(doc.get('isLoaded'))){
        issue = App.Position.createRecord({ id: type });
        issue.get('store').commit();
      }
    });
  },

  _feed: function(){
    // create a CouchDB `/_change` feed listener
    feed = EmberCouchDBKit.ChangesFeed.create({ db: 'boards', content: {"include_docs": true, "timeout":1000}});
    // all upcoming changes are passed to `_handleChanges` callback through `longpool` strategy
    feed.longpoll(this._handleChanges, this);
  },

  _handleChanges: function(data){
    indexController = this.controllerFor("index");
    store = indexController.get('store')
    data.forEach(function(obj){
      if ((obj.doc.text)&&(obj.doc.type =='issue')&&(obj.doc.board)){
        App.Boards.forEach(function(type) {
          if (!(obj.doc._deleted)&&(indexController.get('controllers.%@'.fmt(type)).get('content').mapProperty('id').indexOf(obj.doc._id) >= 0)){
            App.Issue.find(obj.doc._id).reload();
          }else{
            store.adapterForType(App.Issue).load(store, App.Issue, obj.doc);
            if (obj.doc.board == type){<commit_msg>Itergrated App.Position behavior<commit_after>var App = Ember.Application.create();



// Models

App.Store = DS.Store.extend({
  revision: 13,
  adapter: EmberCouchDBKit.DocumentAdapter.create({db: 'boards'})
});

App.Issue = DS.Model.extend({
  text: DS.attr('string'),
  type: DS.attr('string', {defaultValue: 'issue'}),
  board: DS.attr('string')
});

App.Position = DS.Model.extend({
  issues: DS.hasMany('App.Issue', {embeded: true}),
  type: DS.attr('string', {defaultValue: 'position'})
});


App.Boards = ['common', 'intermediate', 'advanced'];



// Routes

App.IndexRoute = Ember.Route.extend({

  setupController: function(controller, model) {
    this._feed();
    //this._setupPosition();
    self = this;
    App.Boards.forEach(function(type) {
      controller = self.controllerFor(type);

      controller.set('position', App.Position.find(type));
      //
      controller.addObserver('content', controller, function(){
        controller.get('position').set('issues', controller.get('content'));
        controller.get('position.store').commit();
      });
      //
      controller.get('position').one('didLoad', function() {
        controller.set('content', controller.get('position.issues'));
      });
    });
  },

  renderTemplate: function() {
    this.render();
    this.render('board',{outlet: 'common', into: 'index', controller: 'common'});
    this.render('board',{outlet: 'intermediate', into: 'index', controller: 'intermediate'});
    this.render('board',{outlet: 'advanced', into: 'index', controller: 'advanced'});
  },

  _setupPosition: function() {
    App.Boards.forEach(function(type) {
      doc = App.Position.find(type);
      if (!(doc.get('isLoaded'))){
        issue = App.Position.createRecord({ id: type });
        issue.get('store').commit();
      }
    });
  },

  _feed: function(){
    // create a CouchDB `/_change` feed listener
    feed = EmberCouchDBKit.ChangesFeed.create({ db: 'boards', content: {"include_docs": true, "timeout":1000}});
    // all upcoming changes are passed to `_handleChanges` callback through `longpool` strategy
    //feed.longpoll(this._handleChanges, this);
  },

  _handleChanges: function(data){
    indexController = this.controllerFor("index");
    store = indexController.get('store')
    data.forEach(function(obj){
      if ((obj.doc.text)&&(obj.doc.type =='issue')&&(obj.doc.board)){
        App.Boards.forEach(function(type) {
          if (!(obj.doc._deleted)&&(indexController.get('controllers.%@'.fmt(type)).get('content').mapProperty('id').indexOf(obj.doc._id) >= 0)){
            App.Issue.find(obj.doc._id).reload();
          }else{
            store.adapterForType(App.Issue).load(store, App.Issue, obj.doc);
            if (obj.doc.board == type){
{'fraction_non_alphanumeric': 0.19123661148977605, 'fraction_numerical': 0.002726387536514119, 'mean_word_length': 3.664850136239782, 'pattern_counts': {'":': 4, '<': 3, '<?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': '5964110', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1586, 'n_words': 280}