shifted cron jobs to serverless+scheduler, switches instead of checboxes
This commit is contained in:
parent
d5f9681fd8
commit
ea21ecccd3
38
admin.py
38
admin.py
@ -5,7 +5,7 @@ from pathlib import Path
|
||||
import sys
|
||||
from cmd import Cmd
|
||||
|
||||
stage_dir = '_playlist-manager'
|
||||
stage_dir = '.music-tools'
|
||||
scss_rel_path = Path('src', 'scss', 'style.scss')
|
||||
css_rel_path = Path('build', 'style.css')
|
||||
|
||||
@ -98,6 +98,42 @@ class Admin(Cmd):
|
||||
print('>> deploying')
|
||||
self.deploy_function('run_user_playlist')
|
||||
|
||||
# all playlists cron job
|
||||
def do_playlist_cron(self, args):
|
||||
self.prepare_stage()
|
||||
self.prepare_main('cron')
|
||||
|
||||
print('>> deploying')
|
||||
self.deploy_function('run_all_playlists')
|
||||
|
||||
# all stats refresh cron job
|
||||
def do_playlist_stats(self, args):
|
||||
self.prepare_stage()
|
||||
self.prepare_main('cron')
|
||||
|
||||
print('>> deploying')
|
||||
self.deploy_function('run_all_playlist_stats')
|
||||
|
||||
# all tags cron job
|
||||
def do_tags_cron(self, args):
|
||||
self.prepare_stage()
|
||||
self.prepare_main('cron')
|
||||
|
||||
print('>> deploying')
|
||||
self.deploy_function('run_all_tags')
|
||||
|
||||
# redeploy all cron job functions
|
||||
def do_all_cron(self, args):
|
||||
self.prepare_stage()
|
||||
self.prepare_main('cron')
|
||||
|
||||
print('>> deploying playlists')
|
||||
self.deploy_function('run_all_playlists')
|
||||
print('>> deploying stats')
|
||||
self.deploy_function('run_all_playlist_stats')
|
||||
print('>> deploying tags')
|
||||
self.deploy_function('run_all_tags')
|
||||
|
||||
def do_exit(self, args):
|
||||
exit(0)
|
||||
|
||||
|
13
main.cron.py
Normal file
13
main.cron.py
Normal file
@ -0,0 +1,13 @@
|
||||
from music.cloud.tasks import update_all_user_playlists, refresh_all_user_playlist_stats, update_all_user_tags
|
||||
|
||||
|
||||
def run_all_playlists(event, context):
|
||||
update_all_user_playlists()
|
||||
|
||||
|
||||
def run_all_playlist_stats(event, context):
|
||||
refresh_all_user_playlist_stats()
|
||||
|
||||
|
||||
def run_all_tags(event, context):
|
||||
update_all_user_tags()
|
@ -8,7 +8,7 @@ import logging
|
||||
from datetime import datetime
|
||||
|
||||
from music.api.decorators import login_required, login_or_basic_auth, \
|
||||
admin_required, gae_cron, cloud_task, validate_json, validate_args
|
||||
admin_required, cloud_task, validate_json, validate_args, spotify_link_required
|
||||
from music.cloud import queue_run_user_playlist, offload_or_run_user_playlist
|
||||
from music.cloud.tasks import update_all_user_playlists, update_playlists
|
||||
|
||||
@ -289,16 +289,9 @@ def run_users(user=None):
|
||||
return jsonify({'message': 'executed all users', 'status': 'success'}), 200
|
||||
|
||||
|
||||
@blueprint.route('/playlist/run/users/cron', methods=['GET'])
|
||||
@gae_cron
|
||||
def run_users_cron():
|
||||
|
||||
update_all_user_playlists()
|
||||
return jsonify({'status': 'success'}), 200
|
||||
|
||||
|
||||
@blueprint.route('/playlist/image', methods=['GET'])
|
||||
@login_or_basic_auth
|
||||
@spotify_link_required
|
||||
@validate_args(('name', str))
|
||||
def image(user=None):
|
||||
|
||||
|
@ -4,7 +4,7 @@ import json
|
||||
import os
|
||||
|
||||
from music.api.decorators import admin_required, login_or_basic_auth, lastfm_username_required, \
|
||||
spotify_link_required, cloud_task, gae_cron, validate_args
|
||||
spotify_link_required, cloud_task, validate_args
|
||||
import music.db.database as database
|
||||
from music.cloud.tasks import refresh_all_user_playlist_stats, refresh_user_playlist_stats, refresh_playlist_task
|
||||
from music.tasks.refresh_lastfm_stats import refresh_lastfm_track_stats, \
|
||||
@ -140,13 +140,6 @@ def run_users(user=None):
|
||||
return jsonify({'message': 'executed all users', 'status': 'success'}), 200
|
||||
|
||||
|
||||
@blueprint.route('/playlist/refresh/users/cron', methods=['GET'])
|
||||
@gae_cron
|
||||
def run_users_task():
|
||||
refresh_all_user_playlist_stats()
|
||||
return jsonify({'status': 'success'}), 200
|
||||
|
||||
|
||||
@blueprint.route('/playlist/refresh/user', methods=['GET'])
|
||||
@login_or_basic_auth
|
||||
def run_user(user=None):
|
||||
|
@ -4,9 +4,8 @@ import logging
|
||||
import os
|
||||
import json
|
||||
|
||||
from music.api.decorators import login_or_basic_auth, gae_cron, cloud_task
|
||||
from music.api.decorators import login_or_basic_auth, cloud_task
|
||||
from music.cloud.function import update_tag as serverless_update_tag
|
||||
from music.cloud.tasks import update_all_user_tags
|
||||
from music.tasks.update_tag import update_tag
|
||||
|
||||
from music.model.tag import Tag
|
||||
@ -152,11 +151,3 @@ def run_tag_task():
|
||||
serverless_update_tag(username=payload['username'], tag_id=payload['tag_id'])
|
||||
|
||||
return jsonify({'message': 'executed playlist', 'status': 'success'}), 200
|
||||
|
||||
|
||||
@blueprint.route('/tag/update/users/cron', methods=['GET'])
|
||||
@gae_cron
|
||||
def run_tags_cron():
|
||||
|
||||
update_all_user_tags()
|
||||
return jsonify({'status': 'success'}), 200
|
||||
|
@ -1,8 +1,8 @@
|
||||
import React, { Component } from "react";
|
||||
const axios = require('axios');
|
||||
|
||||
import { Card, Button, CircularProgress, FormControl, TextField, InputLabel, Select, Checkbox, FormControlLabel,
|
||||
CardActions, CardContent, Typography, Grid, MenuItem } from '@material-ui/core';
|
||||
import { Card, Button, CircularProgress, FormControl, TextField, InputLabel, Select, FormControlLabel,
|
||||
CardActions, CardContent, Typography, Grid, MenuItem, Switch } from '@material-ui/core';
|
||||
import { Delete } from '@material-ui/icons';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
@ -356,19 +356,19 @@ export class Edit extends Component{
|
||||
<Grid item xs={12}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox color="primary" name="shuffle" checked={this.state.shuffle} onChange={this.handleCheckChange} />
|
||||
<Switch color="primary" name="shuffle" checked={this.state.shuffle} onChange={this.handleCheckChange} />
|
||||
}
|
||||
labelPlacement="bottom"
|
||||
label="Shuffle"/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox color="primary" checked={this.state.include_recommendations} name="include_recommendations" onChange={this.handleCheckChange} />
|
||||
<Switch color="primary" checked={this.state.include_recommendations} name="include_recommendations" onChange={this.handleCheckChange} />
|
||||
}
|
||||
labelPlacement="bottom"
|
||||
label="Recommendations"/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox color="primary" checked={this.state.include_library_tracks} name="include_library_tracks" onChange={this.handleCheckChange} />
|
||||
<Switch color="primary" checked={this.state.include_library_tracks} name="include_library_tracks" onChange={this.handleCheckChange} />
|
||||
}
|
||||
labelPlacement="bottom"
|
||||
label="Library Tracks"/>
|
||||
@ -428,14 +428,14 @@ export class Edit extends Component{
|
||||
<Grid item xs={12}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox color="primary" checked={this.state.add_this_month} name="add_this_month" onChange={this.handleCheckChange} />
|
||||
<Switch color="primary" checked={this.state.add_this_month} name="add_this_month" onChange={this.handleCheckChange} />
|
||||
}
|
||||
label="This Month"
|
||||
labelPlacement="bottom"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox color="primary" checked={this.state.add_last_month} name="add_last_month" onChange={this.handleCheckChange} />
|
||||
<Switch color="primary" checked={this.state.add_last_month} name="add_last_month" onChange={this.handleCheckChange} />
|
||||
}
|
||||
label="Last Month"
|
||||
labelPlacement="bottom"
|
||||
@ -474,6 +474,7 @@ export class Edit extends Component{
|
||||
|
||||
function ReferenceEntry(props) {
|
||||
return <option value={props.name}>{props.name}</option>;
|
||||
// return <MenuItem value={props.name}>{props.name}</MenuItem>;
|
||||
}
|
||||
|
||||
function ListBlock(props) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { Component } from "react";
|
||||
const axios = require('axios');
|
||||
|
||||
import { Card, Button, CircularProgress, CardActions, CardContent, FormControl, InputLabel, Select, Typography, Grid, TextField, MenuItem, FormControlLabel, Checkbox } from '@material-ui/core';
|
||||
import { Card, Button, CircularProgress, CardActions, CardContent, FormControl, InputLabel, Select, Typography, Grid, TextField, MenuItem, FormControlLabel, Switch } from '@material-ui/core';
|
||||
import { Delete } from '@material-ui/icons';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
@ -325,7 +325,7 @@ class View extends Component{
|
||||
<Grid item xs={12}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox color="primary" checked={this.state.tag.time_objects} name="time_objects" onChange={this.handleCheckChange} />
|
||||
<Switch color="primary" checked={this.state.tag.time_objects} name="time_objects" onChange={this.handleCheckChange} />
|
||||
}
|
||||
label="Time Tag"
|
||||
labelPlacement="bottom"
|
||||
|
Loading…
Reference in New Issue
Block a user