Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions blockstats/blockstats_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def update_profile_url(self, snapshot_id, address, profile_url):
{'snapshot_id': snapshot_id, 'address': address},
{"$set": {"profile_url": profile_url}})

def update_expire_block(self, snapshot_id, address, expire_block):
self._db.identities.find_one_and_update(
{'snapshot_id': snapshot_id, 'address': address},
{"$set": {"expire_block": expire_block}})

def update_is_person(self, snapshot_id, address, is_person):
self._db.identities.find_one_and_update(
{'snapshot_id': snapshot_id, 'address': address}, {"$set": {"is_person": is_person}})
Expand Down
4 changes: 4 additions & 0 deletions blockstats/blockstats_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ def _import_profile_url(self, client, snapshot_id, address):
details = client.download_name_details(address)
zonefile = None
profile_url = None
expire_block = None
if details:
zonefile = details.get('zonefile')
expire_block = details.get('expire_block')
if zonefile:
profile_url = parser.extract_profile_url(zonefile)
if profile_url:
self.dao.update_profile_url(snapshot_id, address, profile_url)
if expire_block:
self.dao.update_expire_block(snapshot_id, address, expire_block)

def import_app_installs_multithreaded(self, snapshot_id, threads=1):
identities = self.dao.get_identities(snapshot_id)
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/dao_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def test_update_profile_url(dao):

assert dao.read_all_identities()[0].get('profile_url') == 'https://testurl.com'

def test_update_expire_block(dao):
timestamp = datetime.datetime.utcnow()
identities = [{'address': '111.id', 'name': '111', 'namespace': 'id'}]

dao.save_identities(snapshot_id='1234', timestamp=timestamp, identities=identities)
dao.update_expire_block(snapshot_id='1234', address='111.id', expire_block=100)

assert dao.read_all_identities()[0].get('expire_block') == 100

def test_update_is_person(dao):
timestamp = datetime.datetime.utcnow()
identities = [{'address': '111.id', 'name': '111', 'namespace': 'id'}]
Expand Down Expand Up @@ -111,4 +120,4 @@ def test_force_remove_snapshot(dao):
assert len(dao.get_identities(snapshot2_id)) == 1

assert len(dao.get_app_installations(snapshot1_id)) == 0
assert len(dao.get_identities(snapshot2_id)) == 1
assert len(dao.get_identities(snapshot2_id)) == 1