Improvement to mass editor loading speed.

pull/1096/head
Louis Vézina 4 years ago
parent 8940ee617d
commit 32f6d0861d

@ -389,6 +389,36 @@ class Series(Resource):
return '', 204
class SeriesEditor(Resource):
@authenticate
def get(self, **kwargs):
draw = request.args.get('draw')
result = database.execute("SELECT sonarrSeriesId, title, languages, hearing_impaired, forced, audio_language "
"FROM table_shows ORDER BY sortTitle")
row_count = len(result)
for item in result:
# Add Datatables rowId
item.update({"DT_RowId": 'row_' + str(item['sonarrSeriesId'])})
# Parse audio language
item.update({"audio_language": {"name": item['audio_language'],
"code2": alpha2_from_language(item['audio_language']) or None,
"code3": alpha3_from_language(item['audio_language']) or None}})
# Parse desired languages
if item['languages'] and item['languages'] != 'None':
item.update({"languages": ast.literal_eval(item['languages'])})
for i, subs in enumerate(item['languages']):
item['languages'][i] = {"name": language_from_alpha2(subs),
"code2": subs,
"code3": alpha3_from_alpha2(subs)}
return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result)
class SeriesEditSave(Resource):
@authenticate
def post(self):
@ -924,6 +954,36 @@ class Movies(Resource):
return '', 204
class MoviesEditor(Resource):
@authenticate
def get(self):
draw = request.args.get('draw')
result = database.execute("SELECT radarrId, title, languages, hearing_impaired, forced, audio_language "
"FROM table_movies ORDER BY sortTitle")
row_count = len(result)
for item in result:
# Add Datatables rowId
item.update({"DT_RowId": 'row_' + str(item['radarrId'])})
# Parse audio language
item.update({"audio_language": {"name": item['audio_language'],
"code2": alpha2_from_language(item['audio_language']) or None,
"code3": alpha3_from_language(item['audio_language']) or None}})
# Parse desired languages
if item['languages'] and item['languages'] != 'None':
item.update({"languages": ast.literal_eval(item['languages'])})
for i, subs in enumerate(item['languages']):
item['languages'][i] = {"name": language_from_alpha2(subs),
"code2": subs,
"code3": alpha3_from_alpha2(subs)}
return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result)
class MoviesEditSave(Resource):
@authenticate
def post(self):
@ -1843,6 +1903,7 @@ api.add_resource(SystemStatus, '/systemstatus')
api.add_resource(SystemReleases, '/systemreleases')
api.add_resource(Series, '/series')
api.add_resource(SeriesEditor, '/series_editor')
api.add_resource(SeriesEditSave, '/series_edit_save')
api.add_resource(Episodes, '/episodes')
api.add_resource(EpisodesSubtitlesDelete, '/episodes_subtitles_delete')
@ -1856,6 +1917,7 @@ api.add_resource(EpisodesHistory, '/episodes_history')
api.add_resource(EpisodesTools, '/episodes_tools')
api.add_resource(Movies, '/movies')
api.add_resource(MoviesEditor, '/movies_editor')
api.add_resource(MoviesEditSave, '/movies_edit_save')
api.add_resource(MovieSubtitlesDelete, '/movie_subtitles_delete')
api.add_resource(MovieSubtitlesDownload, '/movie_subtitles_download')

@ -67,7 +67,7 @@
var event_json = JSON.parse(event);
if (event_json.type === 'movies_editor' && event_json.action === 'update') {
$.ajax({
url: "{{ url_for('api.movies') }}",
url: "{{ url_for('api.movieseditor') }}",
success: function (data) {
if (data.data.length) {
$('#movies').DataTable().ajax.reload(resetPaging = false);
@ -96,7 +96,7 @@
lengthChange: true,
responsive: true,
paging: false,
ajax: "{{ url_for('api.movies') }}",
ajax: "{{ url_for('api.movieseditor') }}",
columnDefs: [{
orderable: false,
className: 'select-checkbox',

@ -67,7 +67,7 @@
var event_json = JSON.parse(event);
if (event_json.type === 'series_editor' && event_json.action === 'update') {
$.ajax({
url: "{{ url_for('api.series') }}",
url: "{{ url_for('api.serieseditor') }}",
success: function (data) {
if (data.data.length) {
$('#series').DataTable().ajax.reload(resetPaging = false);
@ -96,7 +96,7 @@
lengthChange: true,
responsive: true,
paging: false,
ajax: "{{ url_for('api.series') }}",
ajax: "{{ url_for('api.serieseditor') }}",
columnDefs: [{
orderable: false,
className: 'select-checkbox',

Loading…
Cancel
Save