<commit_before>import Ember from 'ember';

var ID_FILTERS = ['contributors', 'funders', 'publishers'];

export default Ember.Component.extend({
    filters: null,
    init () {
      this._super(...arguments);
      let parameters = this.get('parameters');
      var filters = Object.keys(parameters).filter((key) => {
        return key !== "page";
      }).map((key) => {
        return {
          "key": key,
          "value": parameters[key]
        }
      });

      // Find and format all query params that use ids for the value
      var ids = filters.filter((item) => {
          return ID_FILTERS.indexOf(item.key) !== -1;
      }).map((param) => {
          return {key: param.value}
      });

      // Fetch display names
      if (ids.length > 0) {
        this.fetchAgentDetails(ids).then((data) => {
          if (filters) {
            var displayFilters = filters.map((filter) => {
              var value = filter.value;
              data.forEach((agentData) => {
                if (value === agentData.id) {
                  value = agentData.name;
                }
              });
              return {key: filter.key, value: value};
            });
            this.set('filters', displayFilters);
          }
        });
      }},

    fetchAgentDetails: async function(agentList) {
        let agent_details = await Ember.$.ajax({
            url: 'https://dev-labs.cos.io/bulk_get_agents',
            crossDomain: true,
            data: JSON.stringify(agentList),
            type: 'POST',
            contentType: 'application/json'
        });
        return JSON.parse(agent_details);
    },

    actions: {

        removeFilter(filter) {
            let queryParams = {};
            queryParams[filter.key] = undefined;
            this.attrs.transitionToFacet("search", queryParams);
        },

        transitionToFacet(parameter, parameterValue) {
            let queryParams = {};<commit_msg>Remove unneeded check if filters<commit_after>import Ember from 'ember';

var ID_FILTERS = ['contributors', 'funders', 'publishers'];

export default Ember.Component.extend({
    filters: null,
    init () {
      this._super(...arguments);
      let parameters = this.get('parameters');
      var filters = Object.keys(parameters).filter((key) => {
        return key !== "page";
      }).map((key) => {
        return {
          "key": key,
          "value": parameters[key]
        }
      });

      // Find and format all query params that use ids for the value
      var ids = filters.filter((item) => {
          return ID_FILTERS.indexOf(item.key) !== -1;
      }).map((param) => {
          return {key: param.value}
      });

      // Fetch display names
      if (ids.length > 0) {
        this.fetchAgentDetails(ids).then((data) => {
            var displayFilters = filters.map((filter) => {
              var value = filter.value;
              data.forEach((agentData) => {
                if (value === agentData.id) {
                  value = agentData.name;
                }
              });
              return {key: filter.key, value: value};
            });
            this.set('filters', displayFilters);
        });
      }},

    fetchAgentDetails: async function(agentList) {
        let agent_details = await Ember.$.ajax({
            url: 'https://dev-labs.cos.io/bulk_get_agents',
            crossDomain: true,
            data: JSON.stringify(agentList),
            type: 'POST',
            contentType: 'application/json'
        });
        return JSON.parse(agent_details);
    },

    actions: {

        removeFilter(filter) {
            let queryParams = {};
            queryParams[filter.key] = undefined;
            this.attrs.transitionToFacet("search", queryParams);
        },

        transitionToFacet(parameter, parameterValue) {
            let queryParams = {};
{'fraction_non_alphanumeric': 0.1383419689119171, 'fraction_numerical': 0.0010362694300518134, 'mean_word_length': 1.763779527559055, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 19, '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': '2638470', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1033, 'n_words': 226}