Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new feeds. #1073

Merged
merged 1 commit into from
May 28, 2024
Merged
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
75 changes: 42 additions & 33 deletions crawlers/mooncrawl/mooncrawl/reports_crawler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,51 +486,60 @@ def generate_report_nft_dashboard_handler(args: argparse.Namespace):
"cu_land_nft_dashboard_data",
"cu_seaport_feed_polygon",
"cu_breeding_feed",
"cu_shadowcorns_owners",
"cu_shadowcorns_feed",
"cu_previous_day_distributed_rewards",
]:
continue
try:
logger.info(f"Generating report for {query.name}")
data = recive_S3_data_from_query(
client=client,
token=args.moonstream_token,
query_name=query.name,
params=params,
time_await=4,
)

logger.info(f"Generating report for {query.name}")
data = recive_S3_data_from_query(
client=client,
token=args.moonstream_token,
query_name=query.name,
params=params,
time_await=4,
)

logger.info(f"Data recived. Uploading report for {query.name} as json")
logger.info(f"Data recived. Uploading report for {query.name} as json")

# send as json
ext = "json"
# send as json
ext = "json"

url = client.upload_query_results(
json.dumps(data),
key=f"queries/{query.name}/data.{ext}",
bucket=MOONSTREAM_S3_PUBLIC_DATA_BUCKET,
)
url = client.upload_query_results(
json.dumps(data),
key=f"queries/{query.name}/data.{ext}",
bucket=MOONSTREAM_S3_PUBLIC_DATA_BUCKET,
)

logger.info(f"Report uploaded to {url}")
logger.info(f"Report uploaded to {url}")

logger.info(f"Data recived. Uploading report for {query.name} as csv")
logger.info(f"Data recived. Uploading report for {query.name} as csv")

ext = "csv"
csv_buffer = StringIO()
ext = "csv"
csv_buffer = StringIO()

dict_csv_writer = csv.DictWriter(
csv_buffer, fieldnames=data["data"][0].keys(), delimiter=","
)
dict_csv_writer = csv.DictWriter(
csv_buffer, fieldnames=data["data"][0].keys(), delimiter=","
)

# upload to s3 bucket as csv
dict_csv_writer.writeheader()
dict_csv_writer.writerows(data["data"])
# upload to s3 bucket as csv
dict_csv_writer.writeheader()
dict_csv_writer.writerows(data["data"])

url = client.upload_query_results(
data=csv_buffer.getvalue().encode("utf-8"),
key=f"queries/{query.name}/data.{ext}",
bucket=MOONSTREAM_S3_PUBLIC_DATA_BUCKET,
)
url = client.upload_query_results(
data=csv_buffer.getvalue().encode("utf-8"),
key=f"queries/{query.name}/data.{ext}",
bucket=MOONSTREAM_S3_PUBLIC_DATA_BUCKET,
)

logger.info(f"Report uploaded to {url}")
logger.info(f"Report uploaded to {url}")
logger.info(
f"s3://{MOONSTREAM_S3_PUBLIC_DATA_BUCKET}/queries/{query.name}/data.{ext}"
)
except Exception as err:
logger.error(f"Error while generating report for {query.name}. {err}")
continue


def run_tokenomics_orange_dao_handler(args: argparse.Namespace):
Expand Down
Loading