Skip to content

Commit

Permalink
Merge pull request #11 from web3bio/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ZhongFuze authored Nov 7, 2024
2 parents 772d5de + a3d4fca commit 1fd5d0b
Show file tree
Hide file tree
Showing 6 changed files with 706 additions and 50 deletions.
18 changes: 13 additions & 5 deletions src/resolver/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-12 14:10:05
LastEditors: Zella Zhong
LastEditTime: 2024-10-27 20:50:00
LastEditTime: 2024-11-08 00:13:48
FilePath: /data_service/src/resolver/clusters.py
Description:
'''
Expand Down Expand Up @@ -184,7 +184,9 @@ async def query_profile_by_single_clusters(info, query_str):
if len(selected_fields) > 0:
profile_sql = select(ClustersProfile).options(
load_only(*selected_fields))\
.filter(ClustersProfile.cluster_name == query_cluster_name)
.filter(and_(
ClustersProfile.cluster_name == query_cluster_name,
ClustersProfile.is_verified == True))
profile_result = await s.execute(profile_sql)
profile_records = profile_result.scalars().all()
for row in profile_records:
Expand Down Expand Up @@ -259,7 +261,10 @@ async def query_profile_by_single_clusters(info, query_str):
if len(selected_fields) > 0:
profile_sql = select(ClustersProfile).options(
load_only(*selected_fields))\
.filter(and_(ClustersProfile.cluster_name == query_cluster_name, ClustersProfile.name == query_name))
.filter(and_(
ClustersProfile.cluster_name == query_cluster_name,
ClustersProfile.name == query_name,
ClustersProfile.is_verified == True))
profile_result = await s.execute(profile_sql)
one_profile_record = profile_result.scalars().one_or_none()
if one_profile_record is not None:
Expand Down Expand Up @@ -343,13 +348,16 @@ async def query_profile_by_batch_clusters(info, batch_clusters_name):
# only get cluster_name part
checked_clusters.append(name.split('/')[0])

checked_clusters = list(set(checked_clusters))
selected_fields = get_clusters_selected_fields(ClustersProfile, info)
profile_dict = {}
async with get_session() as s:
if len(selected_fields) > 0:
profile_sql = select(ClustersProfile).options(
load_only(*selected_fields))\
.filter(ClustersProfile.cluster_name.in_(checked_clusters))
.filter(and_(
ClustersProfile.cluster_name.in_(checked_clusters),
ClustersProfile.is_verified == True))
profile_result = await s.execute(profile_sql)
profile_records = profile_result.scalars().all()
for row in profile_records:
Expand Down Expand Up @@ -461,7 +469,7 @@ async def query_profile_by_batch_clusters(info, batch_clusters_name):
primary_name=None,
is_primary=False,
expired_at=None,
resolved_address=[],
resolved_address=resolved_addresses,
owner_address=owner_addresses,
profile=profile
))
Expand Down
10 changes: 7 additions & 3 deletions src/resolver/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 18:41:34
LastEditors: Zella Zhong
LastEditTime: 2024-10-30 15:10:26
LastEditTime: 2024-11-07 23:24:00
FilePath: /data_service/src/resolver/ethereum.py
Description:
'''
Expand Down Expand Up @@ -654,17 +654,21 @@ async def query_and_update_missing_query_ids(query_ids):
return identity_records

def filter_ethereum_query_ids(identities):
cnt = 0
final_query_ids = set()
for identity in identities:
cnt += 1
is_evm = is_ethereum_address(identity)
if is_evm:
final_query_ids.add(f"{Platform.ethereum.value},{identity}")
if cnt > QUERY_MAX_LIMIT:
break

return list(final_query_ids)

async def query_ethereum_profile_by_ids_cache(info, identities, require_cache=False):
if len(identities) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)
# if len(identities) > QUERY_MAX_LIMIT:
# return ExceedRangeInput(QUERY_MAX_LIMIT)

filter_query_ids = filter_ethereum_query_ids(identities)
if len(filter_query_ids) == 0:
Expand Down
17 changes: 7 additions & 10 deletions src/resolver/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 19:05:41
LastEditors: Zella Zhong
LastEditTime: 2024-11-07 21:05:51
LastEditTime: 2024-11-08 00:15:19
FilePath: /data_service/src/resolver/fetch.py
Description:
'''
Expand Down Expand Up @@ -51,6 +51,7 @@
from resolver.unstoppabledomains import query_unstoppabledomains_profile_by_ids_cache
from resolver.basenames import query_basenames_profile_by_ids_cache
from resolver.sns import query_sns_profile_by_ids_cache
from resolver.solana import query_solana_profile_by_ids_cache

async def single_fetch(info, platform, identity):
identity_records = []
Expand All @@ -68,10 +69,9 @@ async def single_fetch(info, platform, identity):
# return await query_profile_by_single_lens_handle(info, identity)
identity_records = await query_lens_profile_by_ids_cache(info, [identity], require_cache=True)
elif platform == Platform.solana:
record = await query_profile_by_single_solana(info, identity)
identity_records.append(record)
identity_records = await query_solana_profile_by_ids_cache(info, [identity], require_cache=True)
elif platform == Platform.sns:
identity_records = await query_sns_profile_by_ids_cache(info, [identity], require_cache=False)
identity_records = await query_sns_profile_by_ids_cache(info, [identity], require_cache=True)
elif platform == Platform.clusters:
record = await query_profile_by_single_clusters(info, identity)
identity_records.append(record)
Expand Down Expand Up @@ -255,24 +255,21 @@ async def batch_fetch_all(info, vertices_map):
return PlatformNotSupport(platform)

if platform_enum == Platform.ethereum:
# tasks.append(query_profile_by_addresses(info, identities))
tasks.append(query_ethereum_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.ens:
# tasks.append(query_profile_by_ensnames(info, identities))
tasks.append(query_ensname_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.farcaster:
# tasks.append(query_profile_by_fnames(info, identities))
tasks.append(query_farcaster_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.lens:
# tasks.append(query_profile_by_lens_handle(info, identities))
tasks.append(query_lens_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.clusters:
tasks.append(query_profile_by_batch_clusters(info, identities))
elif platform_enum == Platform.basenames:
# tasks.append(query_profile_by_basenames(info, identities))
tasks.append(query_basenames_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.sns:
tasks.append(query_sns_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.solana:
tasks.append(query_profile_by_solana_addresses(info, identities))
tasks.append(query_solana_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.unstoppabledomains:
tasks.append(query_unstoppabledomains_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.bitcoin:
Expand Down
Loading

0 comments on commit 1fd5d0b

Please sign in to comment.