kopia lustrzana https://github.com/bugout-dev/moonstream
Merge pull request #765 from bugout-dev/fix-metadata-crawler
Fix metadata crawlerpull/766/head mooncrawl/v0.2.8
commit
b85939595c
|
@ -4,6 +4,7 @@ from typing import Dict, Any, Optional, List
|
|||
|
||||
from moonstreamdb.blockchain import AvailableBlockchainType, get_label_model
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
from ..data import TokenURIs
|
||||
from ..settings import VIEW_STATE_CRAWLER_LABEL, METADATA_CRAWLER_LABEL, CRAWLER_LABEL
|
||||
|
@ -70,6 +71,7 @@ def get_uris_of_tokens(
|
|||
table = label_model.__tablename__
|
||||
|
||||
metadata_for_parsing = db_session.execute(
|
||||
text(
|
||||
""" SELECT
|
||||
DISTINCT ON(label_data -> 'inputs'-> 0 ) label_data -> 'inputs'-> 0 as token_id,
|
||||
label_data -> 'result' as token_uri,
|
||||
|
@ -87,6 +89,7 @@ def get_uris_of_tokens(
|
|||
block_number :: INT DESC;
|
||||
""".format(
|
||||
table
|
||||
)
|
||||
),
|
||||
{"table": table, "label": VIEW_STATE_CRAWLER_LABEL, "name": "tokenURI"},
|
||||
)
|
||||
|
@ -118,6 +121,7 @@ def get_current_metadata_for_address(
|
|||
table = label_model.__tablename__
|
||||
|
||||
current_metadata = db_session.execute(
|
||||
text(
|
||||
""" SELECT
|
||||
DISTINCT ON(label_data ->> 'token_id') label_data ->> 'token_id' as token_id
|
||||
FROM
|
||||
|
@ -130,6 +134,7 @@ def get_current_metadata_for_address(
|
|||
block_number :: INT DESC;
|
||||
""".format(
|
||||
table
|
||||
)
|
||||
),
|
||||
{"address": address, "label": METADATA_CRAWLER_LABEL},
|
||||
)
|
||||
|
@ -159,6 +164,7 @@ def get_tokens_id_wich_may_updated(
|
|||
table = label_model.__tablename__
|
||||
|
||||
tokens = db_session.execute(
|
||||
text(
|
||||
"""
|
||||
with token_id_latest_events as (
|
||||
SELECT
|
||||
|
@ -208,6 +214,7 @@ def get_tokens_id_wich_may_updated(
|
|||
token_id_latest_events.block_timestamp > metadata_state.block_timestamp
|
||||
""".format(
|
||||
table, table
|
||||
)
|
||||
),
|
||||
{
|
||||
"address": address,
|
||||
|
@ -234,6 +241,7 @@ def clean_labels_from_db(
|
|||
table = label_model.__tablename__
|
||||
|
||||
db_session.execute(
|
||||
text(
|
||||
"""
|
||||
WITH lates_token_metadata AS (
|
||||
SELECT
|
||||
|
@ -257,6 +265,7 @@ def clean_labels_from_db(
|
|||
AND {}.id not in (select id from lates_token_metadata) RETURNING {}.block_number;
|
||||
""".format(
|
||||
table, table, table, table
|
||||
)
|
||||
),
|
||||
{"address": address, "label": METADATA_CRAWLER_LABEL},
|
||||
)
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
Moonstream crawlers version.
|
||||
"""
|
||||
|
||||
MOONCRAWL_VERSION = "0.2.7"
|
||||
MOONCRAWL_VERSION = "0.2.8"
|
||||
|
|
Ładowanie…
Reference in New Issue