forked from DebaucheryLibrarian/traxxx
				
			Added entity scene count function.
This commit is contained in:
		
							parent
							
								
									b62ae00c54
								
							
						
					
					
						commit
						250618df8b
					
				|  | @ -117,9 +117,7 @@ function curateEntity(entity, parent, releases) { | |||
| 	if (entity.parent || parent) curatedEntity.parent = curateEntity(entity.parent || parent); | ||||
| 	if (releases) curatedEntity.releases = releases.map((release) => curateRelease(release)); | ||||
| 
 | ||||
| 	if (entity.connection) { | ||||
| 		curatedEntity.sceneTotal = entity.connection.totalCount; | ||||
| 	} | ||||
| 	curatedEntity.sceneTotal = entity.sceneTotal; | ||||
| 
 | ||||
| 	return curatedEntity; | ||||
| } | ||||
|  |  | |||
|  | @ -62,12 +62,10 @@ function initEntitiesActions(store, router) { | |||
| 							independent | ||||
| 							hasLogo | ||||
| 							${campaignsFragment} | ||||
| 							sceneTotal | ||||
| 							children: childEntitiesConnection { | ||||
| 								totalCount | ||||
| 							} | ||||
| 							connection: scenesConnection { | ||||
| 								totalCount | ||||
| 							} | ||||
| 						} | ||||
|                     } | ||||
| 					${campaignsFragment} | ||||
|  |  | |||
|  | @ -0,0 +1,11 @@ | |||
| exports.up = async (knex) => knex.raw(` | ||||
| 	CREATE OR REPLACE FUNCTION entities_scene_total(entity entities) RETURNS integer AS $$ | ||||
| 		SELECT COUNT(id) | ||||
| 		FROM releases | ||||
| 		WHERE releases.entity_id = entity.id; | ||||
| 	$$ LANGUAGE SQL STABLE; | ||||
| `);
 | ||||
| 
 | ||||
| exports.down = async (knex) => knex.raw(` | ||||
| 	DROP FUNCTION IF EXISTS entities_scene_total; | ||||
| `);
 | ||||
		Loading…
	
		Reference in New Issue