<commit_before>import React, { Component } from 'react';
import Request from 'superagent';
import Articles from './Articles';

const FILTERS = {
  country: {
    '--':'--',
    au: 'au',
    de: 'de',
    gb: 'gb',
    in: 'in',
    it: 'it',
    us: 'us',
  },
  language: {
    '--':'--',
    de: 'de',
    en: 'en',
  },
  category: {
    '--':'--',
    business: 'business',
    entertainment: 'entertainment',
    general: ' general',
    technology: 'technology',
  },
};

export default class SourceList extends Component {
  /**
   * Creates an instance of SourceList.
   *
   * @memberof SourceList
   */
  constructor() {
    super();
    this.state = {
      sources: [],
      search: '',
      sourceId: ['bbc-news'],
      articles: null,
      currentFilter: {
        filterKey: 'language',
        filterValue: 'en',
      },
      filters: FILTERS,
    };

    this.onSubmit = this.onSubmit.bind(this);
    this.updateSearch = this.updateSearch.bind(this);
    this.fetchArticles = this.fetchArticles.bind(this);
    this.fetchSources = this.fetchSources.bind(this);
    this.handleChangeCategory = this.handleChangeCategory.bind(this);
  }

  // Called before the render method is executed
  componentWillMount() {
    this.fetchSources();
    this.fetchArticles();
  }

  // Call the fetchArticles function when source state changes
  onSubmit(id) {
    this.setState({ sourceId: id }, () => {
      this.fetchArticles();
    });
  }

  // Get a list of sources using the provided filtering parameters
  fetchSources() {
    const url = `https://newsapi.org/v1/sources?${this.state.currentFilter.filterKey}=${this.state.currentFilter.filterValue}`;
    Request.get(url).then((response) => {
      this.setState((Object.assign({}, { sources: response.body.sources })
      ));
    });
  }

  fetchArticles() {
  // Fetch for articles related to the respective sourceId when called
    const url = `https://newsapi.org/v1/articles?source=${this.state.sourceId}&sortBy=top&apiKey=<KEY>`;
    Request<commit_msg>update sort<commit_after>import React, { Component } from 'react';
import Request from 'superagent';
import Articles from './Articles';

const FILTERS = {
  country: {
    '--':'--',
    au: 'au',
    de: 'de',
    gb: 'gb',
    in: 'in',
    it: 'it',
    us: 'us',
  },
  language: {
    '--':'--',
    de: 'de',
    en: 'en',
  },
  category: {
    '--':'--',
    business: 'business',
    entertainment: 'entertainment',
    general: ' general',
    technology: 'technology',
  },
};

export default class SourceList extends Component {
  /**
   * Creates an instance of SourceList.
   *
   * @memberof SourceList
   */
  constructor() {
    super();
    this.state = {
      sources: [],
      search: '',
      sourceId: ['bbc-news'],
      articles: null,
      currentFilter: {
        filterKey: 'language',
        filterValue: 'en',
      },
      filters: FILTERS,
    };

    this.onSubmit = this.onSubmit.bind(this);
    this.updateSearch = this.updateSearch.bind(this);
    this.fetchArticles = this.fetchArticles.bind(this);
    this.fetchSources = this.fetchSources.bind(this);
    this.handleChangeCategory = this.handleChangeCategory.bind(this);
  }

  // Called before the render method is executed
  componentWillMount() {
    this.fetchSources();
    this.fetchArticles();
  }

  // Call the fetchArticles function when source state changes
  onSubmit(id) {
    this.setState({ sourceId: id }, () => {
      this.fetchArticles();
    });
  }

  // Get a list of sources using the provided filtering parameters
  fetchSources() {
    const url = `https://newsapi.org/v1/sources?${this.state.currentFilter.filterKey}=${this.state.currentFilter.filterValue}`;
    Request.get(url).then((response) => {
      this.setState((Object.assign({}, { sources: response.body.sources })
      ));
    });
  }

  fetchArticles() {
  // Fetch for articles related to the respective sourceId when called
    const url = `https://newsapi.org/v1/articles?source=${this.state.sourceId}&sortBy=latest&apiKey=<KEY>`;
    Request
{'fraction_non_alphanumeric': 0.16070988415085039, 'fraction_numerical': 0.0009859502095144195, 'mean_word_length': 2.835538752362949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '107191', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1269, 'n_words': 274}