Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSubmit(event) {
this.setState({
result: alasql(this.state.query, [this.props.plays])
});
}
componentDidMount() {
this.setState({
result: alasql(this.state.query, [this.state.plays])
});
}
static getDerivedStateFromProps(nextProps, prevState) {
return {
months: alasql(`SELECT year, timeStamp->getMonth() as month, COUNT(id) as plays, SUM(duration) as duration FROM ? WHERE excluded = false GROUP BY year, timeStamp->getMonth() ORDER BY timeStamp ASC`,[nextProps.plays])
};
}
static getDerivedStateFromProps(nextProps, prevState) {
var years = alasql(`SELECT COUNT(id) as plays, SUM(duration) as duration, year FROM ? WHERE excluded = false GROUP BY year ORDER BY year ASC`,[nextProps.plays]);
for (let index = 0; index < years.length; index++) {
years[index].songs = alasql(`SELECT name, artist, COUNT(id) as plays, SUM(duration) as duration FROM ? WHERE year = ${years[index].year} AND excluded = false GROUP BY name, artist ORDER BY SUM(duration) DESC`,[nextProps.plays]);
}
return {
years: years
};
}
static getDerivedStateFromProps(nextProps, prevState) {
var years = alasql(`SELECT COUNT(id) as plays, SUM(duration) as duration, year FROM ? WHERE excluded = false GROUP BY year ORDER BY year ASC`,[nextProps.plays]);
for (let index = 0; index < years.length; index++) {
years[index].songs = alasql(`SELECT name, artist, COUNT(id) as plays, SUM(duration) as duration FROM ? WHERE year = ${years[index].year} AND excluded = false GROUP BY name, artist ORDER BY SUM(duration) DESC`,[nextProps.plays]);
}
return {
years: years
};
}