Add methods PDB.get_thing_count for all thing types.
This commit is contained in:
		
							parent
							
								
									f640268793
								
							
						
					
					
						commit
						2a9b2cd095
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		|  | @ -46,6 +46,9 @@ class PDBAlbumMixin: | ||||||
|     def get_album_by_id(self, id): |     def get_album_by_id(self, id): | ||||||
|         return self.get_thing_by_id('album', id) |         return self.get_thing_by_id('album', id) | ||||||
| 
 | 
 | ||||||
|  |     def get_album_count(self): | ||||||
|  |         return self.sql_select_one('SELECT COUNT(id) FROM albums')[0] | ||||||
|  | 
 | ||||||
|     def get_albums(self): |     def get_albums(self): | ||||||
|         yield from self.get_things(thing_type='album') |         yield from self.get_things(thing_type='album') | ||||||
| 
 | 
 | ||||||
|  | @ -125,6 +128,9 @@ class PDBBookmarkMixin: | ||||||
|     def get_bookmark(self, id): |     def get_bookmark(self, id): | ||||||
|         return self.get_thing_by_id('bookmark', id) |         return self.get_thing_by_id('bookmark', id) | ||||||
| 
 | 
 | ||||||
|  |     def get_bookmark_count(self): | ||||||
|  |         return self.sql_select_one('SELECT COUNT(id) FROM bookmarks')[0] | ||||||
|  | 
 | ||||||
|     def get_bookmarks(self): |     def get_bookmarks(self): | ||||||
|         yield from self.get_things(thing_type='bookmark') |         yield from self.get_things(thing_type='bookmark') | ||||||
| 
 | 
 | ||||||
|  | @ -355,6 +361,9 @@ class PDBPhotoMixin: | ||||||
|         photo = self.get_cached_instance('photo', photo_row) |         photo = self.get_cached_instance('photo', photo_row) | ||||||
|         return photo |         return photo | ||||||
| 
 | 
 | ||||||
|  |     def get_photo_count(self): | ||||||
|  |         return self.sql_select_one('SELECT COUNT(id) FROM photos')[0] | ||||||
|  | 
 | ||||||
|     def get_photos_by_id(self, ids): |     def get_photos_by_id(self, ids): | ||||||
|         return self.get_things_by_id('photo', ids) |         return self.get_things_by_id('photo', ids) | ||||||
| 
 | 
 | ||||||
|  | @ -1082,6 +1091,9 @@ class PDBTagMixin: | ||||||
|         tag = self.get_cached_instance('tag', tag_row) |         tag = self.get_cached_instance('tag', tag_row) | ||||||
|         return tag |         return tag | ||||||
| 
 | 
 | ||||||
|  |     def get_tag_count(self): | ||||||
|  |         return self.sql_select_one('SELECT COUNT(id) FROM tags')[0] | ||||||
|  | 
 | ||||||
|     def get_tags(self): |     def get_tags(self): | ||||||
|         ''' |         ''' | ||||||
|         Yield all Tags in the database. |         Yield all Tags in the database. | ||||||
|  | @ -1198,6 +1210,9 @@ class PDBUserMixin: | ||||||
|         else: |         else: | ||||||
|             raise exceptions.NoSuchUser(username or id) |             raise exceptions.NoSuchUser(username or id) | ||||||
| 
 | 
 | ||||||
|  |     def get_user_count(self): | ||||||
|  |         return self.sql_select_one('SELECT COUNT(id) FROM users')[0] | ||||||
|  | 
 | ||||||
|     def get_user_id_or_none(self, user_obj_or_id): |     def get_user_id_or_none(self, user_obj_or_id): | ||||||
|         ''' |         ''' | ||||||
|         For methods that create photos, albums, etc., we sometimes associate |         For methods that create photos, albums, etc., we sometimes associate | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue