<commit_before>define([
  'backbone', 'handlebars', 'moment',
  'connect/collections/Subscriptions',
  'connect/views/SubscriptionListItemView',
  'text!connect/templates/subscriptionList.handlebars'
], function(Backbone, Handlebars, moment, Subscriptions, SubscriptionListItemView, tpl) {

  'use strict';

  var SubscriptionListView = Backbone.View.extend({
    template: Handlebars.compile(tpl),

    initialize: function() {
      this.subscriptions = new Subscriptions();
      this.listenTo(this.subscriptions, 'sync', this.render);
      this.subscriptions.fetch();

      this.render();
    },

    render: function() {
      this.$el.html(this.template());

      var $tableBody = this.$('#user-subscriptions-table-body');
      this.subscriptions.each(function(subscription) {
        var view = new SubscriptionListItemView({
          subscription: subscription});
        $tableBody.append(view.el);
      });
    }
  });

  return SubscriptionListView;

});
<commit_msg>Sort subscription list by date<commit_after>define([
  'backbone', 'handlebars', 'moment',
  'connect/collections/Subscriptions',
  'connect/views/SubscriptionListItemView',
  'text!connect/templates/subscriptionList.handlebars'
], function(Backbone, Handlebars, moment, Subscriptions, SubscriptionListItemView, tpl) {

  'use strict';

  var SubscriptionListView = Backbone.View.extend({
    template: Handlebars.compile(tpl),

    initialize: function() {
      this.subscriptions = new Subscriptions();
      this.listenTo(this.subscriptions, 'sync', this.render);
      this.subscriptions.fetch();

      this.render();
    },

    render: function() {
      this.$el.html(this.template());

      var sortedSubscriptions = new Subscriptions(
        this.subscriptions.sortBy(function(subscription) {
          return -moment(subscription.get('created')).unix();
        })
      );

      var $tableBody = this.$('#user-subscriptions-table-body');
      sortedSubscriptions.each(function(subscription) {
        var view = new SubscriptionListItemView({
          subscription: subscription});
        $tableBody.append(view.el);
      });
    }
  });

  return SubscriptionListView;

});

{'fraction_non_alphanumeric': 0.13813675998164296, 'fraction_numerical': 0.0, 'mean_word_length': 3.6284501061571124, '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': '372227', 'n_tokens_mistral': 618, 'n_tokens_neox': 612, 'n_words': 103}