Rozepsání, co se děje v anotaci a dict comprehension
This commit is contained in:
		
							parent
							
								
									5958262240
								
							
						
					
					
						commit
						7677d77ad2
					
				
					 1 changed files with 4 additions and 0 deletions
				
			
		|  | @ -439,7 +439,11 @@ def body_resitelu_odjakziva(rocnik, resitele): | ||||||
| #				pricti_body(body_odjakziva, r, hodn.body) | #				pricti_body(body_odjakziva, r, hodn.body) | ||||||
| 
 | 
 | ||||||
| # Zkusíme agregovat: | # Zkusíme agregovat: | ||||||
|  | 	# Následující řádek přidá ke každému řešiteli údaj ".body" se součtem jejich bodů | ||||||
| 	resitele_s_body = Resitel.objects.annotate(body=Sum('reseni__hodnoceni__body')) | 	resitele_s_body = Resitel.objects.annotate(body=Sum('reseni__hodnoceni__body')) | ||||||
|  | 	# Teď jen z QuerySetu řešitelů anotovaných body vygenerujeme slovník indexovaný řešitelským id obsahující body | ||||||
|  | 	# ... ale jen ro řešitele, které dostaneme jako parametr. | ||||||
|  | 	# TODO: Zjistit, co ten parametr říká a proč je potřeba | ||||||
| 	body_odjakziva = {int(res.id) : res.body for res in resitele_s_body if res in resitele} | 	body_odjakziva = {int(res.id) : res.body for res in resitele_s_body if res in resitele} | ||||||
| 	return body_odjakziva | 	return body_odjakziva | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Pavel 'LEdoian' Turinsky
						Pavel 'LEdoian' Turinsky