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

test: add logs to help debug redis lookup errors #261

Merged
merged 1 commit into from
Oct 18, 2023
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
20 changes: 20 additions & 0 deletions api/src/dataloaders/collection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use async_graphql::{dataloader::Loader as DataLoader, FieldError, Result};
use hub_core::tracing::info;
use poem::async_trait;
use redis::{AsyncCommands, Client as Redis};
use sea_orm::{prelude::*, FromQueryResult, QueryFilter, QuerySelect};
Expand Down Expand Up @@ -76,8 +77,13 @@ impl DataLoader<Uuid> for TotalMintsLoader {

for key in keys {
let redis_key = format!("collection:{key}:total_mints");
info!("total mints loader - get: redis_key: {}", redis_key);
match redis_connection.get::<_, i64>(&redis_key).await {
Ok(value) => {
info!(
"total mints loader - get: redis_key: {} value: {:?}",
redis_key, value
);
results.insert(*key, value);
},
Err(_) => {
Expand Down Expand Up @@ -113,6 +119,11 @@ impl DataLoader<Uuid> for TotalMintsLoader {
let count = count_results.get(&key).copied().unwrap_or_default();
let redis_key = format!("collection:{key}:total_mints");

info!(
"total mints loader - insert: redis_key: {} count: {:?}",
redis_key, count
);

redis_connection
.set::<_, i64, Option<i64>>(&redis_key, count)
.await?;
Expand Down Expand Up @@ -156,8 +167,13 @@ impl DataLoader<Uuid> for SupplyLoader {

for key in keys {
let redis_key = format!("collection:{key}:supply");
info!("supply loader - get: redis_key: {}", redis_key);
match redis_connection.get::<_, Option<i64>>(&redis_key).await {
Ok(value) => {
info!(
"supply loader - get: redis_key: {} value: {:?}",
redis_key, value
);
results.insert(*key, value);
},
Err(_) => {
Expand Down Expand Up @@ -217,6 +233,10 @@ impl DataLoader<Uuid> for SupplyLoader {
for key in computed_supplies {
let count = count_results.get(&key).copied();
let redis_key = format!("collection:{key}:supply");
info!(
"supply loader - insert: redis_key: {} count: {:?}",
redis_key, count
);

redis_connection
.set::<_, Option<i64>, Option<i64>>(&redis_key, count)
Expand Down
Loading