Private
Public Access
1
0

background upload now really in background job

This commit is contained in:
Sander Roosendaal
2021-12-17 08:48:20 +01:00
parent 03ab63fe33
commit 27a560c5a7
5 changed files with 31 additions and 7 deletions

View File

@@ -28,7 +28,8 @@ from rowingdata import (
from rowers.tasks import ( from rowers.tasks import (
handle_sendemail_unrecognized,handle_setcp, handle_sendemail_unrecognized,handle_setcp,
handle_getagegrouprecords, handle_update_wps handle_getagegrouprecords, handle_update_wps,
handle_request_post
) )
from rowers.tasks import handle_zip_file from rowers.tasks import handle_zip_file
@@ -76,6 +77,7 @@ allowedcolumns = [key for key,value in strokedatafields.items()]
#from async_messages import messages as a_messages #from async_messages import messages as a_messages
import os import os
import zipfile import zipfile
from zipfile import BadZipFile
import pandas as pd import pandas as pd
import numpy as np import numpy as np
import itertools import itertools
@@ -2119,7 +2121,11 @@ def new_workout_from_file(r, f2,
uploadoptions['file'] = datafile uploadoptions['file'] = datafile
url = settings.UPLOAD_SERVICE_URL url = settings.UPLOAD_SERVICE_URL
response = requests.post(url,uploadoptions) job = myqueue(queuehigh,
handle_request_post,
url,
uploadoptions
)
except BadZipFile: # pragma: no cover except BadZipFile: # pragma: no cover
pass pass

View File

@@ -38,6 +38,7 @@ from django.contrib.auth.decorators import login_required
from rowingdata import rowingdata from rowingdata import rowingdata
import pandas as pd import pandas as pd
from rowers.models import Rower,Workout from rowers.models import Rower,Workout
from rowers.tasks import handle_request_post
import rowers.dataprep as dataprep import rowers.dataprep as dataprep
from rowers.dataprep import columndict from rowers.dataprep import columndict
@@ -237,9 +238,15 @@ def get_polar_workouts(user):
'file':filename, 'file':filename,
} }
url = reverse('workout_upload_api') url = reverse('workout_upload_api')
response = requests.post(url,json_data)
if response.status_code == 200:
job = myqueue(queuehigh,
handle_request_post,
url,
json_data
)
exercise_dict['filename'] = filename exercise_dict['filename'] = filename
else: else:
exercise_dict['filename'] = '' exercise_dict['filename'] = ''

View File

@@ -284,6 +284,12 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|',workouttype='rower'):
return sums,sa,results return sums,sa,results
@app.task
def handle_request_post(url, data,debug=False, **kwargs):
response = requests.post(url,data)
return response.status_code
@app.task @app.task
def add(x, y): # pragma: no cover def add(x, y): # pragma: no cover
return x + y return x + y

View File

@@ -203,6 +203,7 @@ from rowers.plannedsessions import *
from rowers.tasks import handle_makeplot,handle_otwsetpower,handle_sendemailtcx,handle_sendemailcsv from rowers.tasks import handle_makeplot,handle_otwsetpower,handle_sendemailtcx,handle_sendemailcsv
from rowers.tasks import ( from rowers.tasks import (
handle_sendemail_unrecognized,handle_sendemailnewcomment, handle_sendemail_unrecognized,handle_sendemailnewcomment,
handle_request_post,
handle_sendemailsummary, handle_sendemailsummary,
handle_rp3_async_workout, handle_rp3_async_workout,
handle_send_template_email, handle_send_template_email,

View File

@@ -5443,7 +5443,11 @@ def workout_upload_view(request,
url = settings.UPLOAD_SERVICE_URL url = settings.UPLOAD_SERVICE_URL
response = requests.post(url,uploadoptions) job = myqueue(queuehigh,
handle_request_post,
url,
uploadoptions
)
messages.info( messages.info(
request, request,