func (c Client) FindStashBoxScenesByFingerprints(ctx context.Context, ids []int) ([][]*models.ScrapedScene, error) {
	var fingerprints [][]*graphql.FingerprintQueryInput

	if err := c.txnManager.WithReadTxn(ctx, func(r models.ReaderRepository) error {
		qb := r.Scene()

		for _, sceneID := range ids {
			scene, err := qb.Find(sceneID)
			if err != nil {
				return err
			}

			if scene == nil {
				return fmt.Errorf("scene with id %d not found", sceneID)
			}

			var sceneFPs []*graphql.FingerprintQueryInput

			if scene.Checksum.Valid {
				sceneFPs = append(sceneFPs, &graphql.FingerprintQueryInput{
					Hash:      scene.Checksum.String,
					Algorithm: graphql.FingerprintAlgorithmMd5,
				})
			}

			if scene.OSHash.Valid {
				sceneFPs = append(sceneFPs, &graphql.FingerprintQueryInput{
					Hash:      scene.OSHash.String,
					Algorithm: graphql.FingerprintAlgorithmOshash,
				})
			}

			if scene.Phash.Valid {
				phashStr := utils.PhashToString(scene.Phash.Int64)
				sceneFPs = append(sceneFPs, &graphql.FingerprintQueryInput{
					Hash:      phashStr,
					Algorithm: graphql.FingerprintAlgorithmPhash,
				})
			}

			fingerprints = append(fingerprints, sceneFPs)
		}

		return nil
	}); err != nil {
		return nil, err
	}

	return c.findStashBoxScenesByFingerprints(ctx, fingerprints)
}
// FindStashBoxScenesByFingerprints queries stash-box for scenes using every
// scene's MD5/OSHASH checksum, or PHash, and returns results in the same order
// as the input slice.
FindStashBoxScenesByFingerprints queries stash-box for scenes using every
scene's MD5/OSHASH checksum, or PHash, and returns results in the same order
as the input slice.
// FindStashBoxScenesByFingerprints queries stash - box for scenes using every // scene ' s MD5 / OSHASH checksum or PHash and returns results in the same order // as the input slice .
func (c Client) FindStashBoxScenesByFingerprints(ctx context.Context, ids []int) ([][]*models.ScrapedScene, error) {
	var fingerprints [][]*graphql.FingerprintQueryInput
	if err := c.txnManager.WithReadTxn(ctx, func(r models.ReaderRepository) error {
		qb := r.Scene()
		for _, sceneID := range ids {
			scene, err := qb.Find(sceneID)
			if err != nil {
				return err
			}
			if scene == nil {
				return fmt.Errorf("scene with id %d not found", sceneID)
			}
			var sceneFPs []*graphql.FingerprintQueryInput
			if scene.Checksum.Valid {
				sceneFPs = append(sceneFPs, &graphql.FingerprintQueryInput{
					Hash:      scene.Checksum.String,
					Algorithm: graphql.FingerprintAlgorithmMd5,
				})
			}
			if scene.OSHash.Valid {
				sceneFPs = append(sceneFPs, &graphql.FingerprintQueryInput{
					Hash:      scene.OSHash.String,
					Algorithm: graphql.FingerprintAlgorithmOshash,
				})
			}
			if scene.Phash.Valid {
				phashStr := utils.PhashToString(scene.Phash.Int64)
				sceneFPs = append(sceneFPs, &graphql.FingerprintQueryInput{
					Hash:      phashStr,
					Algorithm: graphql.FingerprintAlgorithmPhash,
				})
			}
			fingerprints = append(fingerprints, sceneFPs)
		}
		return nil
	}); err != nil {
		return nil, err
	}
	return c.findStashBoxScenesByFingerprints(ctx, fingerprints)
}
func ( c Client ) FindStashBoxScenesByFingerprints ( ctx context . Context , ids [ ] int ) ( [ ] [ ] * models . ScrapedScene , error ) { var fingerprints [ ] [ ] * graphql . FingerprintQueryInput if err := c . txnManager . WithReadTxn ( ctx , func ( r models . ReaderRepository ) error { qb := r . Scene ( ) for _ , sceneID := range ids { scene , err := qb . Find ( sceneID ) if err != nil { return err } if scene == nil { return fmt . Errorf ( " " , sceneID ) } var sceneFPs [ ] * graphql . FingerprintQueryInput if scene . Checksum . Valid { sceneFPs = append ( sceneFPs , & graphql . FingerprintQueryInput { Hash : scene . Checksum . String , Algorithm : graphql . FingerprintAlgorithmMd5 , } ) } if scene . OSHash . Valid { sceneFPs = append ( sceneFPs , & graphql . FingerprintQueryInput { Hash : scene . OSHash . String , Algorithm : graphql . FingerprintAlgorithmOshash , } ) } if scene . Phash . Valid { phashStr := utils . PhashToString ( scene . Phash . Int64 ) sceneFPs = append ( sceneFPs , & graphql . FingerprintQueryInput { Hash : phashStr , Algorithm : graphql . FingerprintAlgorithmPhash , } ) } fingerprints = append ( fingerprints , sceneFPs ) } return nil } ) ; err != nil { return nil , err } return c . findStashBoxScenesByFingerprints ( ctx , fingerprints ) }
FindStashBoxScenesByFingerprints queries stash-box for scenes using every
scene's MD5/OSHASH checksum, or PHash, and returns results in the same order
as the input slice.
FindStashBoxScenesByFingerprints queries stash - box for scenes using every scene ' s MD5 / OSHASH checksum or PHash and returns results in the same order as the input slice .