<commit_before>// import {graphql} from 'gatsby';
import React from 'react';
import querystring from 'querystring';
import PropTypes from 'prop-types';
import {navigate} from 'gatsby';

import Layout from '../layout';
import useFilterHooks from '../components/FiltersHooks';
import SEO from '../components/SEO';
import Footer from '../components/Footer';
import Views from '../components/Views';
import SearchResults from '../components/SearchResults';
import SearchBox from '../components/SearchBox';
import Filters from '../components/Filters';

const doSearch = (data, setResults) => {
    const {categories, labels, page, query, sort} = data;
    const params = querystring.stringify({
        categories,
        labels,
        page,
        q: query,
        sort
    });
    const url = `/api/plugins?${params}`;
    fetch(url)
        .then((response) => {
            if (response.status >= 300 || response.status < 200) {
                const error = new Error(response.statusText);
                error.response = response;
                throw error;
            }
            return response;
        })
        .then(response => response.json())
        .then(setResults);
};



function SearchPage({location}) {
    const [showFilter, setShowFilter] = React.useState(true);
    const [results, setResults] = React.useState(null);
    const {
        sort, setSort,
        clearCriteria,
        categories, toggleCategory,
        labels, toggleLabel,
        view, setView,
        page, setPage,
        query, setQuery,
        setData
    } = useFilterHooks();

    const handleOnSubmit = (e) => {<commit_msg>We can cors now, so use cors<commit_after>// import {graphql} from 'gatsby';
import React from 'react';
import querystring from 'querystring';
import PropTypes from 'prop-types';
import {navigate} from 'gatsby';

import Layout from '../layout';
import useFilterHooks from '../components/FiltersHooks';
import SEO from '../components/SEO';
import Footer from '../components/Footer';
import Views from '../components/Views';
import SearchResults from '../components/SearchResults';
import SearchBox from '../components/SearchBox';
import Filters from '../components/Filters';

const doSearch = (data, setResults) => {
    const {categories, labels, page, query, sort} = data;
    const params = querystring.stringify({
        categories,
        labels,
        page,
        q: query,
        sort
    });
    const url = `https://plugins.jenkins.io/api/plugins?${params}`;
    fetch(url, {mode: 'cors'})
        .then((response) => {
            if (response.status >= 300 || response.status < 200) {
                const error = new Error(response.statusText);
                error.response = response;
                throw error;
            }
            return response;
        })
        .then(response => response.json())
        .then(setResults);
};



function SearchPage({location}) {
    const [showFilter, setShowFilter] = React.useState(true);
    const [results, setResults] = React.useState(null);
    const {
        sort, setSort,
        clearCriteria,
        categories, toggleCategory,
        labels, toggleLabel,
        view, setView,
        page, setPage,
        query, setQuery,
        setData
    } = useFilterHooks();

    const handleOnSubmit = (e) => {
{'fraction_non_alphanumeric': 0.12940114354498947, 'fraction_numerical': 0.0036111947035811012, 'mean_word_length': 2.52492046659597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '3186640', 'n_tokens_mistral': 922, 'n_tokens_neox': 897, 'n_words': 258}