Skip to content

Commit

Permalink
feat: add index for registry field (WebOfTrust#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenkan authored Feb 13, 2024
1 parent e8445b4 commit fafe5b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/keria/db/basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def generateIndexes(self, said):
# Assign single field Schema and ISSUER index and ISSUER/SCHEMA:
self.schIdx.add(keys=(said,), val=SCHEMA_FIELD.qb64b)
self.schIdx.add(keys=(said,), val=ISSUER_FIELD.qb64b)
self.schIdx.add(keys=(said,), val=REGISTRY_FIELD.qb64b)
subkey = f"{ISSUER_FIELD.qb64}.{SCHEMA_FIELD.qb64}"
self.schIdx.add(keys=(said,), val=subkey.encode("UTF-8"))

Expand Down
8 changes: 8 additions & 0 deletions tests/app/test_basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_seeker(helpers, seeder, mockHelpingNowUTC):
# Verify the indexes created for the QVI schema
assert indexes == ['5AABAA-s',
'5AABAA-i',
'4AABA-ri',
'5AABAA-i.5AABAA-s',
'4AAB-a-i',
'4AAB-a-i.5AABAA-s',
Expand Down Expand Up @@ -73,6 +74,7 @@ def test_seeker(helpers, seeder, mockHelpingNowUTC):
# Test the indexes assigned to the LE schema
assert indexes == ['5AABAA-s',
'5AABAA-i',
'4AABA-ri',
'5AABAA-i.5AABAA-s',
'4AAB-a-i',
'4AAB-a-i.5AABAA-s',
Expand Down Expand Up @@ -122,6 +124,12 @@ def test_seeker(helpers, seeder, mockHelpingNowUTC):
saids = seeker.find({}).limit(50)
assert len(list(saids)) == 50

saids = seeker.find({ '-ri': "EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4" })
assert len(list(saids)) == 25

saids = seeker.find({ '-ri': "EAzc9zFLaK22zbrKDGIgKtrpDBNKWKvl8B0FKYAo19z_" })
assert len(list(saids)) == 0

saids = seeker.find({'-d': "EAzc9zFLaK22zbrKDGIgKtrpDBNKWKvl8B0FKYAo19z_"})
assert list(saids) == ['EAzc9zFLaK22zbrKDGIgKtrpDBNKWKvl8B0FKYAo19z_']

Expand Down

0 comments on commit fafe5b6

Please sign in to comment.