updates trail filter and sort with elevation loss
This commit is contained in:
342
db/migrations/1731157565_updated_trails_filter.go
Normal file
342
db/migrations/1731157565_updated_trails_filter.go
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/pocketbase/dbx"
|
||||||
|
"github.com/pocketbase/pocketbase/daos"
|
||||||
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
|
"github.com/pocketbase/pocketbase/models/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
m.Register(func(db dbx.Builder) error {
|
||||||
|
dao := daos.New(db);
|
||||||
|
|
||||||
|
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
options := map[string]any{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance,\n COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, \n COALESCE(MAX(trails.elevation_loss), 0) AS max_elevation_loss, \n COALESCE(MAX(trails.duration), 0) AS max_duration, \n COALESCE(MIN(trails.distance), 0) AS min_distance, \n COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, \n COALESCE(MIN(trails.elevation_loss), 0) AS min_elevation_loss, \n COALESCE(MIN(trails.duration), 0) AS min_duration \nFROM users \n LEFT JOIN trails ON \n users.id = trails.author OR \n trails.public = 1 OR \n EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
||||||
|
}`), &options); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.SetOptions(options)
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("ixfa8u8m")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("bhn0jj40")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("3kujiwzh")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("yf3zwzn4")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("skvtkith")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("gydvo1ug")
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_max_distance := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "oyvx8oaq",
|
||||||
|
"name": "max_distance",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_max_distance); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_max_distance)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_max_elevation_gain := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "4xu7voeh",
|
||||||
|
"name": "max_elevation_gain",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_max_elevation_gain); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_max_elevation_gain)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_max_elevation_loss := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "sqzilovv",
|
||||||
|
"name": "max_elevation_loss",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_max_elevation_loss); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_max_elevation_loss)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_max_duration := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "rupidtew",
|
||||||
|
"name": "max_duration",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_max_duration); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_max_duration)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_min_distance := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "2y7dbhf9",
|
||||||
|
"name": "min_distance",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_min_distance); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_min_distance)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_min_elevation_gain := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "ooiwexpc",
|
||||||
|
"name": "min_elevation_gain",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_min_elevation_gain); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_min_elevation_gain)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_min_elevation_loss := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "ondmfwce",
|
||||||
|
"name": "min_elevation_loss",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_min_elevation_loss); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_min_elevation_loss)
|
||||||
|
|
||||||
|
// add
|
||||||
|
new_min_duration := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "kcrhzmaw",
|
||||||
|
"name": "min_duration",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), new_min_duration); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(new_min_duration)
|
||||||
|
|
||||||
|
return dao.SaveCollection(collection)
|
||||||
|
}, func(db dbx.Builder) error {
|
||||||
|
dao := daos.New(db);
|
||||||
|
|
||||||
|
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
options := map[string]any{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
||||||
|
}`), &options); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.SetOptions(options)
|
||||||
|
|
||||||
|
// add
|
||||||
|
del_max_distance := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "ixfa8u8m",
|
||||||
|
"name": "max_distance",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), del_max_distance); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(del_max_distance)
|
||||||
|
|
||||||
|
// add
|
||||||
|
del_max_elevation_gain := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "bhn0jj40",
|
||||||
|
"name": "max_elevation_gain",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), del_max_elevation_gain); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(del_max_elevation_gain)
|
||||||
|
|
||||||
|
// add
|
||||||
|
del_max_duration := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "3kujiwzh",
|
||||||
|
"name": "max_duration",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), del_max_duration); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(del_max_duration)
|
||||||
|
|
||||||
|
// add
|
||||||
|
del_min_distance := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "yf3zwzn4",
|
||||||
|
"name": "min_distance",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), del_min_distance); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(del_min_distance)
|
||||||
|
|
||||||
|
// add
|
||||||
|
del_min_elevation_gain := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "skvtkith",
|
||||||
|
"name": "min_elevation_gain",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), del_min_elevation_gain); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(del_min_elevation_gain)
|
||||||
|
|
||||||
|
// add
|
||||||
|
del_min_duration := &schema.SchemaField{}
|
||||||
|
if err := json.Unmarshal([]byte(`{
|
||||||
|
"system": false,
|
||||||
|
"id": "gydvo1ug",
|
||||||
|
"name": "min_duration",
|
||||||
|
"type": "json",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"maxSize": 1
|
||||||
|
}
|
||||||
|
}`), del_min_duration); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
collection.Schema.AddField(del_min_duration)
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("oyvx8oaq")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("4xu7voeh")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("sqzilovv")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("rupidtew")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("2y7dbhf9")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("ooiwexpc")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("ondmfwce")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.Schema.RemoveField("kcrhzmaw")
|
||||||
|
|
||||||
|
return dao.SaveCollection(collection)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/meilisearch/meilisearch-go"
|
||||||
|
"github.com/pocketbase/dbx"
|
||||||
|
|
||||||
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
client := meilisearch.NewClient(meilisearch.ClientConfig{
|
||||||
|
Host: os.Getenv("MEILI_URL"),
|
||||||
|
APIKey: os.Getenv("MEILI_MASTER_KEY"),
|
||||||
|
})
|
||||||
|
m.Register(func(db dbx.Builder) error {
|
||||||
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
|
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = client.Index("trails").UpdateFilterableAttributes(&[]string{
|
||||||
|
"_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "public", "shares",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}, func(db dbx.Builder) error {
|
||||||
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
|
"created", "date", "difficulty", "distance", "elevation_gain", "name",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = client.Index("trails").UpdateFilterableAttributes(&[]string{
|
||||||
|
"_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "public", "shares",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ func documentFromTrailRecord(r *models.Record, includeShares bool) map[string]in
|
|||||||
"location": r.GetString("location"),
|
"location": r.GetString("location"),
|
||||||
"distance": r.GetFloat("distance"),
|
"distance": r.GetFloat("distance"),
|
||||||
"elevation_gain": r.GetFloat("elevation_gain"),
|
"elevation_gain": r.GetFloat("elevation_gain"),
|
||||||
|
"elevation_loss": r.GetFloat("elevation_loss"),
|
||||||
"duration": r.GetFloat("duration"),
|
"duration": r.GetFloat("duration"),
|
||||||
"difficulty": r.Get("difficulty"),
|
"difficulty": r.Get("difficulty"),
|
||||||
"category": r.Get("category"),
|
"category": r.Get("category"),
|
||||||
|
|||||||
@@ -3,6 +3,17 @@ title: Changelog
|
|||||||
description: What changed in the last patch?
|
description: What changed in the last patch?
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## v0.10.1
|
||||||
|
### Features
|
||||||
|
- Adds elevation loss to trails. Please note that trails created before this version will have a default elevation loss of 0. Edit & save to update.
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- Fixes bug that caused auto-added summit logs to not have distance, durtaion etc.
|
||||||
|
- Fixes error in the auto-upload feature
|
||||||
|
- Fixes access permissions for profile page
|
||||||
|
- A summit log is now also created automatically when you upload a trail directly
|
||||||
|
- Fixes link to the API documentation in footer
|
||||||
|
|
||||||
## v0.10.0
|
## v0.10.0
|
||||||
### Features
|
### Features
|
||||||
- A new summit log entry is now added automatically when uploading a new GPX file for a new or existing trail
|
- A new summit log entry is now added automatically when uploading a new GPX file for a new or existing trail
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ login() {
|
|||||||
upload_and_delete() {
|
upload_and_delete() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
|
|
||||||
ls $file
|
ls "$file"
|
||||||
|
|
||||||
# API call to upload file
|
# API call to upload file
|
||||||
response=$(curl -b cookie.txt --location --request PUT "$API_URL/trail/upload" --header 'Content-Type: multipart/form-data' -F "file=@$file" -F "name=$base_name")
|
response=$(curl -b cookie.txt --location --request PUT "$API_URL/trail/upload" --header 'Content-Type: multipart/form-data' -F "file=@$file" -F "name=$base_name")
|
||||||
|
|||||||
@@ -239,17 +239,36 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<hr class="my-4 border-separator" />
|
<hr class="my-4 border-separator" />
|
||||||
|
<p class="text-sm font-medium pb-4">{$_("elevation-loss")}</p>
|
||||||
|
<DoubleSlider
|
||||||
|
minValue={filter.elevationLossMin}
|
||||||
|
maxValue={filter.elevationLossLimit}
|
||||||
|
bind:currentMin={filter.elevationLossMin}
|
||||||
|
bind:currentMax={filter.elevationLossMax}
|
||||||
|
on:set={() => update()}
|
||||||
|
></DoubleSlider>
|
||||||
|
<div class="flex justify-between">
|
||||||
|
<span>{formatElevation(filter.elevationLossMin)}</span>
|
||||||
|
<span
|
||||||
|
>{formatElevation(
|
||||||
|
filter.elevationLossMax,
|
||||||
|
)}{filter.elevationLossMax == filter.elevationLossLimit
|
||||||
|
? "+"
|
||||||
|
: ""}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<hr class="my-4 border-separator" />
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Datepicker
|
<Datepicker
|
||||||
name="startDate"
|
name="startDate"
|
||||||
label={$_('after')}
|
label={$_("after")}
|
||||||
bind:value={filter.startDate}
|
bind:value={filter.startDate}
|
||||||
on:change={update}
|
on:change={update}
|
||||||
></Datepicker>
|
></Datepicker>
|
||||||
<Datepicker
|
<Datepicker
|
||||||
name="endDate"
|
name="endDate"
|
||||||
label={$_('before')}
|
label={$_("before")}
|
||||||
bind:value={filter.endDate}
|
bind:value={filter.endDate}
|
||||||
on:change={update}
|
on:change={update}
|
||||||
></Datepicker>
|
></Datepicker>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
{ text: $_("difficulty"), value: "difficulty" },
|
{ text: $_("difficulty"), value: "difficulty" },
|
||||||
{ text: $_("distance"), value: "distance" },
|
{ text: $_("distance"), value: "distance" },
|
||||||
{ text: $_("elevation-gain"), value: "elevation_gain" },
|
{ text: $_("elevation-gain"), value: "elevation_gain" },
|
||||||
|
{ text: $_("elevation-loss"), value: "elevation_loss" },
|
||||||
];
|
];
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ interface TrailFilter {
|
|||||||
elevationGainMin: number;
|
elevationGainMin: number;
|
||||||
elevationGainMax: number;
|
elevationGainMax: number;
|
||||||
elevationGainLimit: number;
|
elevationGainLimit: number;
|
||||||
|
elevationLossMin: number;
|
||||||
|
elevationLossMax: number;
|
||||||
|
elevationLossLimit: number;
|
||||||
startDate?: string;
|
startDate?: string;
|
||||||
endDate?: string;
|
endDate?: string;
|
||||||
completed?: boolean;
|
completed?: boolean;
|
||||||
@@ -120,6 +123,8 @@ interface TrailFilterValues {
|
|||||||
max_distance: number,
|
max_distance: number,
|
||||||
min_elevation_gain: number,
|
min_elevation_gain: number,
|
||||||
max_elevation_gain: number,
|
max_elevation_gain: number,
|
||||||
|
min_elevation_loss: number,
|
||||||
|
max_elevation_loss: number,
|
||||||
min_durtation: number,
|
min_durtation: number,
|
||||||
max_duration: number,
|
max_duration: number,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ export async function trails_show(id: string, loadGPX?: boolean, f: (url: Reques
|
|||||||
}
|
}
|
||||||
response.expand.gpx_data = gpxData;
|
response.expand.gpx_data = gpxData;
|
||||||
|
|
||||||
|
|
||||||
for (const log of response.expand.summit_logs ?? []) {
|
for (const log of response.expand.summit_logs ?? []) {
|
||||||
const gpxData: string = await fetchGPX(log, f);
|
const gpxData: string = await fetchGPX(log, f);
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ export async function fetchGPX(trail: { gpx?: string } & Record<string, any>, f:
|
|||||||
function buildFilterText(filter: TrailFilter, includeGeo: boolean): string {
|
function buildFilterText(filter: TrailFilter, includeGeo: boolean): string {
|
||||||
let filterText: string = "";
|
let filterText: string = "";
|
||||||
|
|
||||||
filterText += `distance >= ${Math.floor(filter.distanceMin)} AND elevation_gain >= ${Math.floor(filter.elevationGainMin)}`
|
filterText += `distance >= ${Math.floor(filter.distanceMin)} AND elevation_gain >= ${Math.floor(filter.elevationGainMin)} AND elevation_loss >= ${Math.floor(filter.elevationLossMin)}`
|
||||||
|
|
||||||
if (filter.distanceMax < filter.distanceLimit) {
|
if (filter.distanceMax < filter.distanceLimit) {
|
||||||
filterText += ` AND distance <= ${Math.ceil(filter.distanceMax)}`
|
filterText += ` AND distance <= ${Math.ceil(filter.distanceMax)}`
|
||||||
@@ -397,6 +397,10 @@ function buildFilterText(filter: TrailFilter, includeGeo: boolean): string {
|
|||||||
filterText += ` AND elevation_gain <= ${Math.ceil(filter.elevationGainMax)}`
|
filterText += ` AND elevation_gain <= ${Math.ceil(filter.elevationGainMax)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.elevationLossMax < filter.elevationLossLimit) {
|
||||||
|
filterText += ` AND elevation_loss <= ${Math.ceil(filter.elevationLossMax)}`
|
||||||
|
}
|
||||||
|
|
||||||
filterText += ` AND difficulty IN [${filter.difficulty.join(",")}]`
|
filterText += ` AND difficulty IN [${filter.difficulty.join(",")}]`
|
||||||
|
|
||||||
if (filter.startDate) {
|
if (filter.startDate) {
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ export const load: ServerLoad = async ({ params, locals, fetch }) => {
|
|||||||
elevationGainMin: 0,
|
elevationGainMin: 0,
|
||||||
elevationGainMax: filterValues.max_elevation_gain,
|
elevationGainMax: filterValues.max_elevation_gain,
|
||||||
elevationGainLimit: filterValues.max_elevation_gain,
|
elevationGainLimit: filterValues.max_elevation_gain,
|
||||||
|
elevationLossMin: 0,
|
||||||
|
elevationLossMax: filterValues.max_elevation_loss,
|
||||||
|
elevationLossLimit: filterValues.max_elevation_gain,
|
||||||
sort: "created",
|
sort: "created",
|
||||||
sortOrder: "+",
|
sortOrder: "+",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ export const load: ServerLoad = async ({ params, locals, url, fetch }) => {
|
|||||||
elevationGainMin: 0,
|
elevationGainMin: 0,
|
||||||
elevationGainMax: filterValues.max_elevation_gain,
|
elevationGainMax: filterValues.max_elevation_gain,
|
||||||
elevationGainLimit: filterValues.max_elevation_gain,
|
elevationGainLimit: filterValues.max_elevation_gain,
|
||||||
|
elevationLossMin: 0,
|
||||||
|
elevationLossMax: filterValues.max_elevation_loss,
|
||||||
|
elevationLossLimit: filterValues.max_elevation_loss,
|
||||||
sort: "created",
|
sort: "created",
|
||||||
sortOrder: "+",
|
sortOrder: "+",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user