API & Client - fix workouts filters on distance when value is a float

This commit is contained in:
Sam 2021-11-11 08:57:10 +01:00
parent 7a7cd509ed
commit eef66cb735
14 changed files with 36 additions and 30 deletions

View File

@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="/favicon.ico"><![endif]--><link rel="stylesheet" href="/static/css/fork-awesome.min.css"><link rel="stylesheet" href="/static/css/leaflet.css"><title>FitTrackee</title><link href="/static/css/admin.04e24276.css" rel="prefetch"><link href="/static/css/main.c790adb1.css" rel="prefetch"><link href="/static/css/main~workouts.66c5ef05.css" rel="prefetch"><link href="/static/css/profile.b52bc193.css" rel="prefetch"><link href="/static/css/reset.bd9657a8.css" rel="prefetch"><link href="/static/css/workouts.54006dff.css" rel="prefetch"><link href="/static/js/admin.2f1d393d.js" rel="prefetch"><link href="/static/js/chunk-2d0c9189.c81458cc.js" rel="prefetch"><link href="/static/js/chunk-2d0cf391.020c75ea.js" rel="prefetch"><link href="/static/js/chunk-2d0da8f3.c8c3e7e8.js" rel="prefetch"><link href="/static/js/chunk-2d2248b6.d84473c1.js" rel="prefetch"><link href="/static/js/chunk-2d22523a.4b710d99.js" rel="prefetch"><link href="/static/js/main.2d300ca4.js" rel="prefetch"><link href="/static/js/main~workouts.a74990d7.js" rel="prefetch"><link href="/static/js/profile.6a786c1d.js" rel="prefetch"><link href="/static/js/reset.518e646f.js" rel="prefetch"><link href="/static/js/workouts.f85cc044.js" rel="prefetch"><link href="/static/css/app.d06ac220.css" rel="preload" as="style"><link href="/static/js/app.0657b3d3.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.71654064.js" rel="preload" as="script"><link href="/static/css/app.d06ac220.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="fittrackee_client"><link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><body><noscript><strong>We're sorry but FitTrackee doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.71654064.js"></script><script src="/static/js/app.0657b3d3.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="/favicon.ico"><![endif]--><link rel="stylesheet" href="/static/css/fork-awesome.min.css"><link rel="stylesheet" href="/static/css/leaflet.css"><title>FitTrackee</title><link href="/static/css/admin.04e24276.css" rel="prefetch"><link href="/static/css/main.c790adb1.css" rel="prefetch"><link href="/static/css/main~workouts.66c5ef05.css" rel="prefetch"><link href="/static/css/profile.b52bc193.css" rel="prefetch"><link href="/static/css/reset.bd9657a8.css" rel="prefetch"><link href="/static/css/workouts.41068cd8.css" rel="prefetch"><link href="/static/js/admin.2f1d393d.js" rel="prefetch"><link href="/static/js/chunk-2d0c9189.c81458cc.js" rel="prefetch"><link href="/static/js/chunk-2d0cf391.020c75ea.js" rel="prefetch"><link href="/static/js/chunk-2d0da8f3.c8c3e7e8.js" rel="prefetch"><link href="/static/js/chunk-2d2248b6.d84473c1.js" rel="prefetch"><link href="/static/js/chunk-2d22523a.4b710d99.js" rel="prefetch"><link href="/static/js/main.2d300ca4.js" rel="prefetch"><link href="/static/js/main~workouts.a74990d7.js" rel="prefetch"><link href="/static/js/profile.6a786c1d.js" rel="prefetch"><link href="/static/js/reset.518e646f.js" rel="prefetch"><link href="/static/js/workouts.b31be27e.js" rel="prefetch"><link href="/static/css/app.d06ac220.css" rel="preload" as="style"><link href="/static/js/app.17b316f4.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.71654064.js" rel="preload" as="script"><link href="/static/css/app.d06ac220.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="fittrackee_client"><link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><body><noscript><strong>We're sorry but FitTrackee doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.71654064.js"></script><script src="/static/js/app.17b316f4.js"></script></body></html>

View File

@ -64,7 +64,7 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/img/workouts/mountains.svg"
},
{
"revision": "a6b9ff333c570a6df2fd94519c10538e",
"revision": "76e49a3c48738a91db7537ed1f2242eb",
"url": "/index.html"
},
{
@ -80,7 +80,7 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/css/admin.04e24276.css"
},
{
"revision": "f6baf208ef194278aa64",
"revision": "8683d38650a7b7795039",
"url": "/static/css/app.d06ac220.css"
},
{
@ -108,8 +108,8 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/css/reset.bd9657a8.css"
},
{
"revision": "f95074a416d77cca21e7",
"url": "/static/css/workouts.54006dff.css"
"revision": "86702fc4926698b2832b",
"url": "/static/css/workouts.41068cd8.css"
},
{
"revision": "e719f9244c69e28e7d00e725ca1e280e",
@ -196,8 +196,8 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/js/admin.2f1d393d.js"
},
{
"revision": "f6baf208ef194278aa64",
"url": "/static/js/app.0657b3d3.js"
"revision": "8683d38650a7b7795039",
"url": "/static/js/app.17b316f4.js"
},
{
"revision": "bd7d183c9f68e5f4027d",
@ -240,7 +240,7 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/js/reset.518e646f.js"
},
{
"revision": "f95074a416d77cca21e7",
"url": "/static/js/workouts.f85cc044.js"
"revision": "86702fc4926698b2832b",
"url": "/static/js/workouts.b31be27e.js"
}
]);

View File

@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts(
"/precache-manifest.cf4ee6309ccad810ffa908b5895175ac.js"
"/precache-manifest.751220f20eaac9a8e0f91e29852ce340.js"
);
workbox.core.setCacheNameDetails({prefix: "fittrackee_client"});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -713,7 +713,7 @@ class TestGetWorkoutsWithFilters(ApiTestCaseMixin):
client, auth_token = self.get_test_client_and_auth_token(app)
response = client.get(
'/api/workouts?distance_from=5&distance_to=8',
'/api/workouts?distance_from=5&distance_to=8.1',
headers=dict(Authorization=f'Bearer {auth_token}'),
)

View File

@ -193,10 +193,12 @@ class Workout(BaseModel):
<= datetime.datetime.strptime(date_to, '%Y-%m-%d')
if date_to
else True,
Workout.distance >= int(distance_from)
Workout.distance >= float(distance_from)
if distance_from
else True,
Workout.distance <= int(distance_to) if distance_to else True,
Workout.distance <= float(distance_to)
if distance_to
else True,
Workout.duration >= convert_in_duration(duration_from)
if duration_from
else True,
@ -233,10 +235,12 @@ class Workout(BaseModel):
<= datetime.datetime.strptime(date_to, '%Y-%m-%d')
if date_to
else True,
Workout.distance >= int(distance_from)
Workout.distance >= float(distance_from)
if distance_from
else True,
Workout.distance <= int(distance_to) if distance_to else True,
Workout.distance <= float(distance_to)
if distance_to
else True,
Workout.duration >= convert_in_duration(duration_from)
if duration_from
else True,

View File

@ -220,10 +220,12 @@ def get_workouts(auth_user_id: int) -> Union[Dict, HttpResponse]:
Workout.workout_date < date_to + timedelta(seconds=1)
if date_to
else True,
Workout.distance >= int(distance_from)
Workout.distance >= float(distance_from)
if distance_from
else True,
Workout.distance <= int(distance_to) if distance_to else True,
Workout.distance <= float(distance_to)
if distance_to
else True,
Workout.moving >= convert_in_duration(duration_from)
if duration_from
else True,

View File

@ -53,7 +53,7 @@
name="distance_from"
type="number"
min="0"
step="1"
step="0.1"
:value="$route.query.distance_from"
@change="handleFilterChange"
/>
@ -62,7 +62,7 @@
name="distance_to"
type="number"
min="0"
step="1"
step="0.1"
:value="$route.query.distance_to"
@change="handleFilterChange"
/>
@ -104,7 +104,7 @@
name="ave_speed_from"
:value="$route.query.ave_speed_from"
@change="handleFilterChange"
step="1"
step="0.1"
type="number"
/>
<span>{{ $t('workouts.TO') }}</span>
@ -113,7 +113,7 @@
name="ave_speed_to"
:value="$route.query.ave_speed_to"
@change="handleFilterChange"
step="1"
step="0.1"
type="number"
/>
</div>
@ -130,7 +130,7 @@
name="max_speed_from"
:value="$route.query.max_speed_from"
@change="handleFilterChange"
step="1"
step="0.1"
type="number"
/>
<span>{{ $t('workouts.TO') }}</span>
@ -139,7 +139,7 @@
name="max_speed_to"
:value="$route.query.max_speed_to"
@change="handleFilterChange"
step="1"
step="0.1"
type="number"
/>
</div>