<commit_before>import React, {useState, useEffect} from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import TimeAgo from 'react-timeago';

import Checksum from './Checksum';
import InstallViaCLI from './InstallViaCLI';

import {formatter} from '../commons/helper';

import './PluginReleases.css';


function PluginReleases({pluginId, versions}) {
    const [isLoading, setIsLoading] = useState(false);
    const [releases, setReleases] = useState([]);

    useEffect(() => {
        const fetchData = async () => {
            setIsLoading(true);
            const result = await axios(`/api/plugin/${pluginId}/releases`);
            let releases = [];
            if (result && result.data && result.data.releases) {
                releases = result.data.releases;
            }
            setReleases(releases);
            setIsLoading(false);
        };
        fetchData();
        return;
    }, []);

    if (isLoading) {
        return (<div className="spinner-wrapper">
            <div className="spinner-border" role="status">
                <span className="sr-only">Loading...</span>
            </div>
        </div>);
    }
    
    if (!versions) {
        return (<div id="pluginReleases--container" className="container" />);
    }
    
    return (
        <div id="pluginReleases--container" className="container">
            {versions.map(version => {
                const release = releases.find(release => version.version === release.tag_name.replace(/^[^0-9]*/, '')) || {};
                return (
                    <div key={version.id} className="item card">
                        <div className="card-header">
                            <h5 className="card-title d-flex justify-content-between">
                                <div><a href={version.url}>{release.name || version.version}</a></div>
                                <div>
                                    <TimeAgo date={new Date(version.buildDate)} formatter={formatter}/>
                                </div>
                            </h5>
                        </div>
                        <div className="card-body">
                            <div>
                                <Checksum type="SHA-1" value={version.sha1} />
                                <Checksum type="SHA-256" value={version.sha256} />
                                <InstallViaCLI pluginId={pluginId} version={version.version} />
                            </div><commit_msg>Don't make pulling live data from api service required, if it fails, log and ignore<commit_after>import React, {useState, useEffect} from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import TimeAgo from 'react-timeago';

import Checksum from './Checksum';
import InstallViaCLI from './InstallViaCLI';

import {formatter} from '../commons/helper';

import './PluginReleases.css';


function PluginReleases({pluginId, versions}) {
    const [releases, setReleases] = useState([]);

    useEffect(() => {
        const fetchData = async () => {
            try {
                const result = await axios(`/api/plugin/${pluginId}/releases`);
                let releases = [];
                if (result && result.data && result.data.releases) {
                    releases = result.data.releases;
                }
                setReleases(releases);
            } catch (e) {
                console.error('fetch api release data', e); // eslint-disable-line no-console
            }
        };
        fetchData();
        return;
    }, []);
    
    if (!versions) {
        return (<div id="pluginReleases--container" className="container" />);
    }
    
    return (
        <div id="pluginReleases--container" className="container">
            {versions.map(version => {
                const release = releases.find(release => version.version === release.tag_name.replace(/^[^0-9]*/, '')) || {};
                return (
                    <div key={version.id} className="item card">
                        <div className="card-header">
                            <h5 className="card-title d-flex justify-content-between">
                                <div><a href={version.url}>{release.name || version.version}</a></div>
                                <div>
                                    <TimeAgo date={new Date(version.buildDate)} formatter={formatter}/>
                                </div>
                            </h5>
                        </div>
                        <div className="card-body">
                            <div>
                                <Checksum type="SHA-1" value={version.sha1} />
                                <Checksum type="SHA-256" value={version.sha256} />
                                <InstallViaCLI pluginId={pluginId} version={version.version} />
                            </div>
{'fraction_non_alphanumeric': 0.13646578140960164, 'fraction_numerical': 0.004902962206332993, 'mean_word_length': 1.5433766233766233, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1765081', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1221, 'n_words': 259}