<commit_before>import React, { Component } from 'react';
import { queue, cancelJob, restartJob, deleteJob, updateJobStatus } from '../../APICalls/APICalls';
import { eventEmitter } from '../../App'

import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import Button from '@material-ui/core/Button';
import TableRow from '@material-ui/core/TableRow';
import { ProgressBar, Grid, Row, Col } from 'react-bootstrap';
import Paper from '@material-ui/core/Paper';
import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';

import Zoom from '@material-ui/core/Zoom';
import DeleteOutline from '@material-ui/icons/DeleteOutline';
import Refresh from '@material-ui/icons/Refresh';
import Info from '@material-ui/icons/Info';
import Cancel from '@material-ui/icons/Cancel';
import TableSortLabel from '@material-ui/core/TableSortLabel';
import Tooltip from '@material-ui/core/Tooltip';
import TablePagination from '@material-ui/core/TablePagination';
import TableFooter from '@material-ui/core/TableFooter';
import TablePaginationActions from '../TablePaginationActions';

import { updateGAPageView } from '../../analytics/ga';
import { completeStatus } from '../../constants';

import { withStyles } from '@material-ui/core';
const styles = theme => ({
	root: {
		width: 'fit-content'
	},
	toolbar: {
		paddingLeft: '300px'
	},
	tablePaginationCaption: {
		fontSize: '15px'
	},
	tablePaginationSelect: {
		fontSize: '15px',
		lineHeight: '20px'
	}
})

class QueueComponent extends Component {

	constructor() {
		super();
		this.state = {
			response: [],
			responsesToDisplay: [],
			selectedTab: 0,
			page: 0,
			rowsPerPage: 10,
			rowsPerPageOptions: [10, 20, 50, 100],
			order: 'desc',
			orderBy: 'job_id'
		};
		this.queueFunc();
		this.interval = setInterval(this.update, 2000);    //making a queue request every 2 seconds
		this.toggleTabs = this.toggleTabs.bind(this);
		this.queueFunc = this.queueFunc.bind(this);
		this.update = this.update.bind(this);

		updateGAPageView();
	}

	capitalizeFirstLetter = (word) => {
		word = word.charAt(0).toUpperCase() + word.substring(1);
		return word;
	}

	componentDidMount() {
		document.title = "OneDataShare - Queue";
	}

	componentWillUnmount() {
		clearInterval(this.interval);
	}

	update = () => {
		let jobIds = this.state.responsesToDisplay.filter(job => !["complete", "failed", "removed", "cancelled"].includes(job.status))
			.map(job => job.uuid)
		if (jobIds.length > 0) {
			updateJobStatus(jobIds, resp => {
				resp.map(job => {
					let existingData = [...this.state.responsesToDisplay]
					let existingJob = existingData.find(item => item.uuid === job.uuid)
					existingJob.bytes.total = job.bytes.total
					existingJob.bytes.done = job.bytes.done
					existingJob.bytes.avg = job.bytes.avg
					this.setState({
						responsesToDisplay: existingData
					})
				})
			}, fail => {
				console.log('Failed to get job updates')
			})
		}
	}

	queueFunc = () => {
		let isHistory = false;<commit_msg>Fixed completed transfers<commit_after>import React, { Component } from 'react';
import { queue, cancelJob, restartJob, deleteJob, updateJobStatus } from '../../APICalls/APICalls';
import { eventEmitter } from '../../App'

import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import Button from '@material-ui/core/Button';
import TableRow from '@material-ui/core/TableRow';
import { ProgressBar, Grid, Row, Col } from 'react-bootstrap';
import Paper from '@material-ui/core/Paper';
import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';

import Zoom from '@material-ui/core/Zoom';
import DeleteOutline from '@material-ui/icons/DeleteOutline';
import Refresh from '@material-ui/icons/Refresh';
import Info from '@material-ui/icons/Info';
import Cancel from '@material-ui/icons/Cancel';
import TableSortLabel from '@material-ui/core/TableSortLabel';
import Tooltip from '@material-ui/core/Tooltip';
import TablePagination from '@material-ui/core/TablePagination';
import TableFooter from '@material-ui/core/TableFooter';
import TablePaginationActions from '../TablePaginationActions';

import { updateGAPageView } from '../../analytics/ga';
import { completeStatus } from '../../constants';

import { withStyles } from '@material-ui/core';
const styles = theme => ({
	root: {
		width: 'fit-content'
	},
	toolbar: {
		paddingLeft: '300px'
	},
	tablePaginationCaption: {
		fontSize: '15px'
	},
	tablePaginationSelect: {
		fontSize: '15px',
		lineHeight: '20px'
	}
})

class QueueComponent extends Component {

	constructor() {
		super();
		this.state = {
			response: [],
			responsesToDisplay: [],
			selectedTab: 0,
			page: 0,
			rowsPerPage: 10,
			rowsPerPageOptions: [10, 20, 50, 100],
			order: 'desc',
			orderBy: 'job_id'
		};
		this.queueFunc();
		this.interval = setInterval(this.update, 2000);    //making a queue request every 2 seconds
		this.toggleTabs = this.toggleTabs.bind(this);
		this.queueFunc = this.queueFunc.bind(this);
		this.update = this.update.bind(this);

		updateGAPageView();
	}

	capitalizeFirstLetter = (word) => {
		word = word.charAt(0).toUpperCase() + word.substring(1);
		return word;
	}

	componentDidMount() {
		document.title = "OneDataShare - Queue";
	}

	componentWillUnmount() {
		clearInterval(this.interval);
	}

	update = () => {
		let jobIds = this.state.responsesToDisplay.filter(job => !["complete", "failed", "removed", "cancelled"].includes(job.status))
			.map(job => job.uuid)
		if (jobIds.length > 0) {
			updateJobStatus(jobIds, resp => {
				resp.map(job => {
					let existingData = [...this.state.responsesToDisplay];
					let existingJob = existingData.find(item => item.uuid === job.uuid);
					existingJob.status = job.status;
					existingJob.bytes.total = job.bytes.total;
					existingJob.bytes.done = job.bytes.done;
					existingJob.bytes.avg = job.bytes.avg;
					this.setState({
						responsesToDisplay: existingData
					})
				})
			}, fail => {
				console.log('Failed to get job updates')
			})
		}
	}

	queueFunc = () => {
		let isHistory = false;
{'fraction_non_alphanumeric': 0.15249494792476295, 'fraction_numerical': 0.00932690812995492, 'mean_word_length': 4.118536197295147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '254538', 'n_tokens_mistral': 2280, 'n_tokens_neox': 2065, 'n_words': 465}