mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-01 19:17:02 -04:00 
			
		
		
		
	Optimization of composite column evaluation: don't compute the user_categories, as they cannot appear in a composite column.
This commit is contained in:
		
							parent
							
								
									f979f0d357
								
							
						
					
					
						commit
						3a2a3f1b4f
					
				| @ -191,7 +191,8 @@ class CacheRow(list): # {{{ | ||||
|             if is_comp: | ||||
|                 id = list.__getitem__(self, 0) | ||||
|                 self._must_do = False | ||||
|                 mi = self.db.get_metadata(id, index_is_id=True) | ||||
|                 mi = self.db.get_metadata(id, index_is_id=True, | ||||
|                                           get_user_categories=False) | ||||
|                 for c in self._composites: | ||||
|                     self[c] =  mi.get(self._composites[c]) | ||||
|         return list.__getitem__(self, col) | ||||
|  | ||||
| @ -823,7 +823,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): | ||||
|             pass | ||||
|         return (path, mi, sequence) | ||||
| 
 | ||||
|     def get_metadata(self, idx, index_is_id=False, get_cover=False): | ||||
|     def get_metadata(self, idx, index_is_id=False, get_cover=False, | ||||
|                      get_user_categories=True): | ||||
|         ''' | ||||
|         Convenience method to return metadata as a :class:`Metadata` object. | ||||
|         Note that the list of formats is not verified. | ||||
| @ -882,16 +883,17 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): | ||||
| 
 | ||||
|         user_cats = self.prefs['user_categories'] | ||||
|         user_cat_vals = {} | ||||
|         for ucat in user_cats: | ||||
|             res = [] | ||||
|             for name,cat,ign in user_cats[ucat]: | ||||
|                 v = mi.get(cat, None) | ||||
|                 if isinstance(v, list): | ||||
|                     if name in v: | ||||
|         if get_user_categories: | ||||
|             for ucat in user_cats: | ||||
|                 res = [] | ||||
|                 for name,cat,ign in user_cats[ucat]: | ||||
|                     v = mi.get(cat, None) | ||||
|                     if isinstance(v, list): | ||||
|                         if name in v: | ||||
|                             res.append([name,cat]) | ||||
|                     elif name == v: | ||||
|                         res.append([name,cat]) | ||||
|                 elif name == v: | ||||
|                     res.append([name,cat]) | ||||
|             user_cat_vals[ucat] = res | ||||
|                 user_cat_vals[ucat] = res | ||||
|         mi.user_categories = user_cat_vals | ||||
| 
 | ||||
|         if get_cover: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user