Add search parameter yield_albums.
The exact details of this feature are still experimental, but I think the concept is sound enough to make it an official parameter.
This commit is contained in:
parent
cc34c4d189
commit
54add8ad61
2 changed files with 11 additions and 5 deletions
|
@ -835,7 +835,7 @@ class Photo(ObjectBase):
|
||||||
[self.id]
|
[self.id]
|
||||||
)
|
)
|
||||||
album_ids = [row[0] for row in album_ids]
|
album_ids = [row[0] for row in album_ids]
|
||||||
albums = list(self.photodb.get_albums_by_id(album_ids))
|
albums = set(self.photodb.get_albums_by_id(album_ids))
|
||||||
return albums
|
return albums
|
||||||
|
|
||||||
def get_tags(self):
|
def get_tags(self):
|
||||||
|
|
|
@ -519,6 +519,8 @@ class PDBPhotoMixin:
|
||||||
orderby=None,
|
orderby=None,
|
||||||
warning_bag=None,
|
warning_bag=None,
|
||||||
give_back_parameters=False,
|
give_back_parameters=False,
|
||||||
|
|
||||||
|
yield_albums=True,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
PHOTO PROPERTIES
|
PHOTO PROPERTIES
|
||||||
|
@ -611,6 +613,10 @@ class PDBPhotoMixin:
|
||||||
If True, the generator's first yield will be a dictionary of all the
|
If True, the generator's first yield will be a dictionary of all the
|
||||||
cleaned up, normalized parameters. The user may have given us loads
|
cleaned up, normalized parameters. The user may have given us loads
|
||||||
of trash, so we should show them the formatting we want.
|
of trash, so we should show them the formatting we want.
|
||||||
|
|
||||||
|
yield_albums:
|
||||||
|
If True, albums which contain photos matching the search will also
|
||||||
|
be returned.
|
||||||
'''
|
'''
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
|
@ -837,10 +843,10 @@ class PDBPhotoMixin:
|
||||||
if limit is not None and photos_received >= limit:
|
if limit is not None and photos_received >= limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
for album in photo.get_containing_albums():
|
if yield_albums:
|
||||||
if album not in seen_albums:
|
new_albums = photo.get_containing_albums().difference(seen_albums)
|
||||||
seen_albums.add(album)
|
yield from new_albums
|
||||||
yield album
|
seen_albums.update(new_albums)
|
||||||
|
|
||||||
photos_received += 1
|
photos_received += 1
|
||||||
yield photo
|
yield photo
|
||||||
|
|
Loading…
Reference in a new issue