Location search must only return results with known location
This commit is contained in:
parent
977b220c51
commit
feda86f0e2
3 changed files with 25 additions and 16 deletions
|
@ -42,13 +42,14 @@
|
||||||
return {
|
return {
|
||||||
zoom: 15,
|
zoom: 15,
|
||||||
position: null,
|
position: null,
|
||||||
center: L.latLng(52.5259279, 13.414496),
|
center: L.latLng(0, 0),
|
||||||
url: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
|
url: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
|
||||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
|
||||||
options: {
|
options: {
|
||||||
icon: {
|
icon: {
|
||||||
iconSize: [40, 40]
|
iconSize: [50, 50]
|
||||||
}
|
},
|
||||||
|
minZoom: 3,
|
||||||
},
|
},
|
||||||
photos: [],
|
photos: [],
|
||||||
results: [],
|
results: [],
|
||||||
|
@ -57,7 +58,7 @@
|
||||||
q: q,
|
q: q,
|
||||||
},
|
},
|
||||||
offset: 0,
|
offset: 0,
|
||||||
pageSize: 100,
|
pageSize: 101,
|
||||||
lastQuery: {},
|
lastQuery: {},
|
||||||
bounds: null,
|
bounds: null,
|
||||||
minLat: null,
|
minLat: null,
|
||||||
|
@ -152,8 +153,11 @@
|
||||||
this.center = photos[0].location;
|
this.center = photos[0].location;
|
||||||
this.bounds = [[this.maxLat, this.minLong], [this.minLat, this.maxLong]];
|
this.bounds = [[this.maxLat, this.minLong], [this.minLat, this.maxLong]];
|
||||||
|
|
||||||
|
if (photos.length > 100) {
|
||||||
|
this.$alert.info('More than 100 photos found');
|
||||||
|
} else {
|
||||||
this.$alert.info(photos.length + ' photos found');
|
this.$alert.info(photos.length + ' photos found');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshList() {
|
refreshList() {
|
||||||
|
@ -169,6 +173,7 @@
|
||||||
const params = {
|
const params = {
|
||||||
count: this.pageSize,
|
count: this.pageSize,
|
||||||
offset: this.offset,
|
offset: this.offset,
|
||||||
|
location: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(params, this.query);
|
Object.assign(params, this.query);
|
||||||
|
@ -187,9 +192,5 @@
|
||||||
this.refreshList();
|
this.refreshList();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* L.icon({
|
|
||||||
html: '<div style="background-image: url(/api/v1/thumbnails/square/40/cc1a022c30fff3d5603f1c3f722ec1960e3fa95e);"></div>',
|
|
||||||
className: 'leaflet-marker-photo' }), */
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
// Query parameters for GET /api/v1/photos
|
// Query parameters for GET /api/v1/photos
|
||||||
type PhotoSearchForm struct {
|
type PhotoSearchForm struct {
|
||||||
Query string `form:"q"`
|
Query string `form:"q"`
|
||||||
|
Location bool `form:"location"`
|
||||||
Tags string `form:"tags"`
|
Tags string `form:"tags"`
|
||||||
Cat string `form:"cat"`
|
Cat string `form:"cat"`
|
||||||
Country string `form:"country"`
|
Country string `form:"country"`
|
||||||
|
|
|
@ -118,7 +118,14 @@ func (s *Search) Photos(form forms.PhotoSearchForm) ([]PhotoSearchResult, error)
|
||||||
Where("photos.deleted_at IS NULL AND files.file_missing = 0").
|
Where("photos.deleted_at IS NULL AND files.file_missing = 0").
|
||||||
Group("photos.id, files.id")
|
Group("photos.id, files.id")
|
||||||
|
|
||||||
|
if form.Location == true {
|
||||||
|
q = q.Where("location_id > 0")
|
||||||
|
|
||||||
if form.Query != "" {
|
if form.Query != "" {
|
||||||
|
likeString := "%" + strings.ToLower(form.Query) + "%"
|
||||||
|
q = q.Where("LOWER(locations.loc_display_name) LIKE ?", likeString)
|
||||||
|
}
|
||||||
|
} else if form.Query != "" {
|
||||||
likeString := "%" + strings.ToLower(form.Query) + "%"
|
likeString := "%" + strings.ToLower(form.Query) + "%"
|
||||||
q = q.Where("tags.tag_label LIKE ? OR LOWER(photo_title) LIKE ? OR LOWER(files.file_main_color) LIKE ?", likeString, likeString, likeString)
|
q = q.Where("tags.tag_label LIKE ? OR LOWER(photo_title) LIKE ? OR LOWER(files.file_main_color) LIKE ?", likeString, likeString, likeString)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue