<commit_before>define(function(require) {
  var SotaDispatcher = require('sota-dispatcher'),
      _ = require('underscore'),
      db = require('../stores/db'),
      sendRequest = require('../mixins/send-request');

  var handlers = {
    getPackagesForFilter: function(payload) {
      sendRequest.doGet('/api/v1/resolver/filters/' + payload.filter + '/package')
        .success(function(packages) {
          db.packagesForFilter.reset(packages);
        });
    },
    getFiltersForPackage: function(payload) {
      sendRequest.doGet('/api/v1/resolver/packages/' + payload.name + '/' + payload.version + '/filter')
        .success(function(filters) {
          db.filtersForPackage.reset(filters);
        });
    },
    addPackageFilter: function(payload) {
      sendRequest.doPut('/api/v1/packages/' + payload.packageFilter.packageName +
        '/' + payload.packageFilter.packageVersion +
        '/filter/' + payload.packageFilter.filterName)
        .success(_.bind(this.refreshPackageFilters, this, payload));
    },
    destroyPackageFilter: function(payload){
      var packageFilter = payload.packageFilter;
      var deleteUrl = '/api/v1/packages' +
        '/' + packageFilter.packageName +
        '/' + packageFilter.packageVersion +
        '/filter/' + packageFilter.filterName;
      sendRequest.doDelete(deleteUrl)
        .success(_.bind(this.refreshPackageFilters, this, payload));
    },
    refreshPackageFilters: function(payload) {
      SotaDispatcher.dispatch({
        actionType: 'get-packages-for-filter',
        filter: payload.packageFilter.filterName
      });
      SotaDispatcher.dispatch({
        actionType: 'get-filters-for-package',
        name: payload.packageFilter.packageName,
        version: payload.packageFilter.packageVersion
      });
    }
  };

  var Handler = (function() {
      this.dispatchCallback = function(payload) {
        switch(payload.actionType) {
          case 'get-packages-for-filter':
            handlers.getPackagesForFilter(payload);
          break;
          case 'get-filters-for-package':
            handlers.getFiltersForPackage(payload);
          break;
          case 'add-package-filter':
            handlers.addPackageFilter(payload);
          break;
          case 'destroy-package-filter':
            handlers.destroyPackageFilter(payload);
          break;
        }
      };
      SotaDispatcher.register(this.dispatchCallback.bind(this));
  });

  return new Handler();

});
<commit_msg>Change end-points for adding/removing package from filter<commit_after>define(function(require) {
  var SotaDispatcher = require('sota-dispatcher'),
      _ = require('underscore'),
      db = require('../stores/db'),
      sendRequest = require('../mixins/send-request');

  var handlers = {
    getPackagesForFilter: function(payload) {
      sendRequest.doGet('/api/v1/resolver/filters/' + payload.filter + '/package')
        .success(function(packages) {
          db.packagesForFilter.reset(packages);
        });
    },
    getFiltersForPackage: function(payload) {
      sendRequest.doGet('/api/v1/resolver/packages/' + payload.name + '/' + payload.version + '/filter')
        .success(function(filters) {
          db.filtersForPackage.reset(filters);
        });
    },
    addPackageFilter: function(payload) {
      sendRequest.doPut('/api/v1/resolver/packages/' + payload.packageFilter.packageName +
        '/' + payload.packageFilter.packageVersion +
        '/filter/' + payload.packageFilter.filterName)
        .success(_.bind(this.refreshPackageFilters, this, payload));
    },
    destroyPackageFilter: function(payload){
      var packageFilter = payload.packageFilter;
      var deleteUrl = '/api/v1/resolver/packages' +
        '/' + packageFilter.packageName +
        '/' + packageFilter.packageVersion +
        '/filter/' + packageFilter.filterName;
      sendRequest.doDelete(deleteUrl)
        .success(_.bind(this.refreshPackageFilters, this, payload));
    },
    refreshPackageFilters: function(payload) {
      SotaDispatcher.dispatch({
        actionType: 'get-packages-for-filter',
        filter: payload.packageFilter.filterName
      });
      SotaDispatcher.dispatch({
        actionType: 'get-filters-for-package',
        name: payload.packageFilter.packageName,
        version: payload.packageFilter.packageVersion
      });
    }
  };

  var Handler = (function() {
      this.dispatchCallback = function(payload) {
        switch(payload.actionType) {
          case 'get-packages-for-filter':
            handlers.getPackagesForFilter(payload);
          break;
          case 'get-filters-for-package':
            handlers.getFiltersForPackage(payload);
          break;
          case 'add-package-filter':
            handlers.addPackageFilter(payload);
          break;
          case 'destroy-package-filter':
            handlers.destroyPackageFilter(payload);
          break;
        }
      };
      SotaDispatcher.register(this.dispatchCallback.bind(this));
  });

  return new Handler();

});

{'fraction_non_alphanumeric': 0.13129710432368108, 'fraction_numerical': 0.0015866719555731853, 'mean_word_length': 2.6202440775305096, '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': '4938716', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1371, 'n_words': 190}