Skip to content

Commit

Permalink
[-] Temporarily remove delete and refetch
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Jan 5, 2024
1 parent dad9bcd commit 823ae73
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 65 deletions.
13 changes: 3 additions & 10 deletions src/controller/tigergraphql/hold.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
error::{Error, Result},
tigergraph::{
delete_vertex_and_edge,
edge::{Hold, HoldRecord},
vertex::{ContractLoadFn, ContractRecord, IdentityLoadFn, IdentityRecord},
},
Expand All @@ -12,7 +11,6 @@ use crate::{
use async_graphql::{Context, Object};
use dataloader::non_cached::Loader;
use strum::IntoEnumIterator;
use tokio::time::{sleep, Duration};
use uuid::Uuid;

#[Object]
Expand Down Expand Up @@ -177,15 +175,10 @@ impl HoldQuery {
let target = Target::NFT(chain, category, contract_address.clone(), id.clone());
match Hold::find_by_id_chain_address(&client, &id, &chain, &contract_address).await? {
Some(hold) => {
let v_id = hold.from_id.clone();
// let v_id = hold.from_id.clone();
if hold.is_outdated() {
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![target], Some(3)).await?;
Ok::<_, Error>(())
});
// Refetch in the background
tokio::spawn(fetch_all(vec![target], Some(3)));
}
Ok(Some(hold))
}
Expand Down
13 changes: 3 additions & 10 deletions src/controller/tigergraphql/identity.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
error::{Error, Result},
tigergraph::{
delete_vertex_and_edge,
edge::{resolve::ResolveReverse, EdgeUnion, HoldRecord},
vertex::{
Identity, IdentityRecord, IdentityWithSource, NeighborReverseLoadFn, OwnerLoadFn,
Expand All @@ -14,7 +13,6 @@ use crate::{
use async_graphql::{Context, Object};
use dataloader::non_cached::Loader;
use strum::IntoEnumIterator;
use tokio::time::{sleep, Duration};
use tracing::{event, Level};
use uuid::Uuid;

Expand Down Expand Up @@ -297,14 +295,9 @@ impl IdentityQuery {
identity,
"Outdated. Delete and Refetching."
);
let v_id = found.v_id.clone();
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![target], Some(3)).await?;
Ok::<_, Error>(())
});
// let v_id = found.v_id.clone();
// Refetch in the background
tokio::spawn(fetch_all(vec![target], Some(3)));
}
Ok(Some(found))
}
Expand Down
36 changes: 9 additions & 27 deletions src/controller/tigergraphql/relation.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use std::vec;

use crate::{
error::{Error, Result},
error::Result,
tigergraph::{
delete_vertex_and_edge,
edge::{RelationUniqueTX, RelationUniqueTXRecord},
vertex::{Identity, IdentityRecord},
},
upstream::{fetch_all, Platform, Target},
util::make_http_client,
};
use async_graphql::{Context, Object};
use tokio::time::{sleep, Duration};
use tracing::{event, Level};

#[Object]
Expand Down Expand Up @@ -89,14 +87,9 @@ impl RelationQuery {
source_identity,
"Outdated. Delete and Refetching."
);
let v_id = found.v_id.clone();
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![source_fetch], Some(3)).await?;
Ok::<_, Error>(())
});
// let v_id = found.v_id.clone();
// Refetch in the background
tokio::spawn(fetch_all(vec![source_fetch], Some(3)));
}
Some(found)
}
Expand Down Expand Up @@ -129,14 +122,8 @@ impl RelationQuery {
target_identity,
"Outdated. Delete and Refetching."
);
let v_id = found.v_id.clone();
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![target_fetch], Some(3)).await?;
Ok::<_, Error>(())
});
// let v_id = found.v_id.clone();
tokio::spawn(fetch_all(vec![target_fetch], Some(3)));
}
Some(found)
}
Expand Down Expand Up @@ -189,14 +176,9 @@ impl RelationQuery {
identity,
"Outdated. Delete and Refetching."
);
let v_id = found.v_id.clone();
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![target], Some(3)).await?;
Ok::<_, Error>(())
});
// let v_id = found.v_id.clone();
// Refetch in the background
tokio::spawn(fetch_all(vec![target], Some(3)));
}
Some(found)
}
Expand Down
24 changes: 6 additions & 18 deletions src/controller/tigergraphql/resolve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
error::{Error, Result},
tigergraph::{
delete_vertex_and_edge,
edge::{resolve::ResolveReverse, Resolve, ResolveEdge},
vertex::IdentityRecord,
},
Expand All @@ -12,7 +11,6 @@ use crate::{
};
use async_graphql::{Context, Object};
use strum::IntoEnumIterator;
use tokio::time::{sleep, Duration};
use uuid::Uuid;

#[Object]
Expand Down Expand Up @@ -153,18 +151,13 @@ impl ResolveQuery {
}
Some(resolve) => {
if resolve.is_outdated() {
let v_id: String = resolve
let _vid: String = resolve
.clone()
.owner
.and_then(|f| Some(f.v_id.clone()))
.unwrap_or("".to_string());
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![target], Some(3)).await?;
Ok::<_, Error>(())
});
// Refetch in the background
tokio::spawn(fetch_all(vec![target], Some(3)));
}
Ok(Some(resolve))
}
Expand All @@ -183,18 +176,13 @@ impl ResolveQuery {
}
Some(resolve) => {
if resolve.is_outdated() {
let v_id: String = resolve
let _vid: String = resolve
.clone()
.owner
.and_then(|f| Some(f.v_id.clone()))
.unwrap_or("".to_string());
tokio::spawn(async move {
// Delete and Refetch in the background
sleep(Duration::from_secs(10)).await;
delete_vertex_and_edge(&client, v_id).await?;
fetch_all(vec![target], Some(3)).await?;
Ok::<_, Error>(())
});
// Refetch in the background
tokio::spawn(fetch_all(vec![target], Some(3)));
}
Ok(Some(resolve))
}
Expand Down
1 change: 1 addition & 0 deletions src/tigergraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl Graph {
}
}

#[allow(dead_code)]
pub async fn delete_vertex_and_edge(
client: &Client<HttpConnector>,
v_id: String,
Expand Down

0 comments on commit 823ae73

Please sign in to comment.