notifications suppressed & some strava checking
This commit is contained in:
@@ -99,6 +99,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
if workoutid:
|
if workoutid:
|
||||||
|
if rower.getemailnotifications and not rower.emailbounced:
|
||||||
email_sent = send_confirm(
|
email_sent = send_confirm(
|
||||||
rower.user, title, link,
|
rower.user, title, link,
|
||||||
uploadoptions
|
uploadoptions
|
||||||
@@ -108,6 +109,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
|||||||
try:
|
try:
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
if workoutid:
|
if workoutid:
|
||||||
|
if rower.getemailnotifications and not rower.emailbounced:
|
||||||
email_sent = send_confirm(
|
email_sent = send_confirm(
|
||||||
rower.user, title, link,
|
rower.user, title, link,
|
||||||
uploadoptions
|
uploadoptions
|
||||||
|
|||||||
@@ -92,14 +92,33 @@ def get_strava_workouts(rower):
|
|||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
stravaids = [int(item['id']) for item in res.json()]
|
stravaids = [int(item['id']) for item in res.json()]
|
||||||
|
stravadata = [{
|
||||||
|
'id':int(item['id']),
|
||||||
|
'elapsed_time':item['elapsed_time'],
|
||||||
|
'start_date':item['start_date'],
|
||||||
|
} for item in res.json()]
|
||||||
|
|
||||||
alldata = {}
|
alldata = {}
|
||||||
for item in res.json():
|
for item in res.json():
|
||||||
alldata[item['id']] = item
|
alldata[item['id']] = item
|
||||||
|
|
||||||
|
|
||||||
|
wfailed = Workout.objects.filter(user=rower,uploadedtostrava=-1)
|
||||||
|
|
||||||
|
for w in wfailed:
|
||||||
|
for item in stravadata:
|
||||||
|
elapsed_time = item['elapsed_time']
|
||||||
|
start_date = item['start_date']
|
||||||
|
stravaid = item['id']
|
||||||
|
if arrow.get(start_date) == arrow.get(w.startdatetime):
|
||||||
|
if datetime.time(seconds=int(elapsed_time)) == w.duration:
|
||||||
|
w.uploadedtostrava = int(stravaid)
|
||||||
|
w.save()
|
||||||
|
|
||||||
knownstravaids = uniqify([
|
knownstravaids = uniqify([
|
||||||
w.uploadedtostrava for w in Workout.objects.filter(user=rower)
|
w.uploadedtostrava for w in Workout.objects.filter(user=rower)
|
||||||
])
|
])
|
||||||
|
|
||||||
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9189,6 +9189,25 @@ def workout_stravaimport_view(request,message=""):
|
|||||||
workouts = []
|
workouts = []
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
stravaids = [int(item['id']) for item in res.json()]
|
stravaids = [int(item['id']) for item in res.json()]
|
||||||
|
stravadata = [{
|
||||||
|
'id':int(item['id']),
|
||||||
|
'elapsed_time':item['elapsed_time'],
|
||||||
|
'start_date':item['start_date'],
|
||||||
|
} for item in res.json()]
|
||||||
|
|
||||||
|
wfailed = Workout.objects.filter(user=rower,uploadedtostrava=-1)
|
||||||
|
|
||||||
|
for w in wfailed:
|
||||||
|
for item in stravadata:
|
||||||
|
elapsed_time = item['elapsed_time']
|
||||||
|
start_date = item['start_date']
|
||||||
|
stravaid = item['id']
|
||||||
|
if arrow.get(start_date) == arrow.get(w.startdatetime):
|
||||||
|
if datetime.time(seconds=int(elapsed_time)) == w.duration:
|
||||||
|
w.uploadedtostrava = int(stravaid)
|
||||||
|
w.save()
|
||||||
|
|
||||||
|
|
||||||
knownstravaids = uniqify([
|
knownstravaids = uniqify([
|
||||||
w.uploadedtostrava for w in Workout.objects.filter(user=r)
|
w.uploadedtostrava for w in Workout.objects.filter(user=r)
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user