Photos: Skip related albums from which a photo was removed #3095

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-06-15 11:35:45 +02:00
parent 1776728570
commit 90a18f6e7d
2 changed files with 15 additions and 4 deletions

View file

@ -71,12 +71,12 @@
</td>
<td>{{ model.getDateString() }}</td>
</tr>
<tr v-if="model.Albums && model.Albums.length">
<tr v-if="albums.length > 0">
<td>
<translate>Albums</translate>
</td>
<td>
<a v-for="(m, i) in model.Albums" :key="i" :href="albumUrl(m)" class="primary--text text-link" target="_blank"><span v-if="i > 0">, </span>{{ m.Title }}</a>
<a v-for="(a, i) in albums" :key="i" :href="a.url" class="primary--text text-link" target="_blank"><span v-if="i > 0">, </span>{{ a.title }}</a>
</td>
</tr>
<tr>
@ -311,6 +311,17 @@ export default {
return result;
},
albums() {
if (!this.model || !this.model.Albums || this.model.Albums.length < 1) {
return [];
}
const results = [];
this.model.Albums.forEach(a => results.push({"title": a.Title, "url": this.albumUrl(a)}));
return results;
},
},
methods: {
formatTime(s) {

View file

@ -500,7 +500,7 @@ func (m *Photo) PreloadKeywords() {
q := Db().NewScope(nil).DB().
Table("keywords").
Select(`keywords.*`).
Joins("JOIN photos_keywords ON photos_keywords.keyword_id = keywords.id AND photos_keywords.photo_id = ?", m.ID).
Joins("JOIN photos_keywords pk ON pk.keyword_id = keywords.id AND pk.photo_id = ?", m.ID).
Order("keywords.keyword ASC")
Log("photo", "preload files", q.Scan(&m.Keywords).Error)
@ -511,7 +511,7 @@ func (m *Photo) PreloadAlbums() {
q := Db().NewScope(nil).DB().
Table("albums").
Select(`albums.*`).
Joins("JOIN photos_albums ON photos_albums.album_uid = albums.album_uid AND photos_albums.photo_uid = ?", m.PhotoUID).
Joins("JOIN photos_albums pa ON pa.album_uid = albums.album_uid AND pa.photo_uid = ? AND pa.hidden = 0", m.PhotoUID).
Where("albums.deleted_at IS NULL").
Order("albums.album_title ASC")