Places: Reduce GeoJON response size

This commit is contained in:
Michael Mayer 2021-11-27 09:30:29 +01:00
parent 1eca490f74
commit f8d64daf00
6 changed files with 10 additions and 19 deletions

View file

@ -17,10 +17,6 @@
</script>
</head>
<body class="{{ .config.Flags }}">
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
your browser</a> to improve your experience.</p>
<![endif]-->
{{template "app.tmpl" .}}

View file

@ -30,11 +30,7 @@
window.__CONFIG__ = {{ .config }};
</script>
</head>
<body class="{{ .config.Flags }}">
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
your browser</a> to improve your experience.</p>
<![endif]-->
<body class="shared {{ .config.Flags }}">
{{template "app.tmpl" .}}

View file

@ -171,6 +171,10 @@ export class Thumb extends Model {
return new this(result);
}
static wrap(data) {
return data.map((values) => new this(values));
}
static fromFiles(photos) {
let result = [];

View file

@ -220,7 +220,7 @@ export default {
return Api.get("geo/view", options).then((r) => {
if (r && r.data && r.data.length > 0) {
// Show photos.
this.$viewer.show(r.data, 0);
this.$viewer.show(Thumb.wrap(r.data), 0);
} else {
// Don't open viewer if nothing was found.
this.$notify.warn(this.$gettext("No pictures found"));

View file

@ -49,7 +49,7 @@ func Geo(f form.SearchGeo) (results GeoResults, err error) {
s = s.Table("photos").
Select(`photos.id, photos.photo_uid, photos.photo_type, photos.photo_lat, photos.photo_lng,
photos.photo_title, photos.photo_description, photos.photo_favorite, photos.taken_at_local,
photos.photo_title, photos.photo_description, photos.photo_favorite, photos.taken_at, photos.taken_at_local,
files.file_hash, files.file_width, files.file_height`).
Joins(`JOIN files ON files.photo_id = photos.id AND
files.file_missing = 0 AND files.file_primary AND files.deleted_at IS NULL`).

View file

@ -22,7 +22,8 @@ type GeoResult struct {
FileHash string `json:"Hash"`
FileWidth int `json:"Width"`
FileHeight int `json:"Height"`
TakenAtLocal time.Time `json:"TakenAt"`
TakenAt time.Time `json:"TakenAt"`
TakenAtLocal time.Time `json:"TakenAtLocal"`
}
// Lat returns the position latitude.
@ -65,16 +66,10 @@ func (photos GeoResults) GeoJSON() ([]byte, error) {
props := gin.H{
"UID": p.PhotoUID,
"Hash": p.FileHash,
"Width": p.FileWidth,
"Height": p.FileHeight,
"TakenAt": p.TakenAtLocal,
"TakenAt": p.TakenAt,
"Title": p.PhotoTitle,
}
if p.PhotoDescription != "" {
props["Description"] = p.PhotoDescription
}
if p.PhotoType != entity.TypeImage && p.PhotoType != entity.TypeDefault {
props["Type"] = p.PhotoType
}