Skip to content

Commit

Permalink
Fix/case sensitive
Browse files Browse the repository at this point in the history
Merge pull request #132 from ZhongFuze/fix/case-sensitive
  • Loading branch information
ZhongFuze authored Apr 23, 2024
2 parents a5e00c3 + b99f9d4 commit 39a3c17
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 50 deletions.
48 changes: 24 additions & 24 deletions src/config/tdb/migrations/LoadingJob_SocialGraph.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,21 @@ CREATE OR REPLACE QUERY find_identity_graph_resolve(STRING platform, STRING iden
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS"
WHERE i.platform != "ENS" AND i.platform != "ens"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS"
WHERE v2.platform != "ENS" AND v2.platform != "ens"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS"
WHERE v1.platform == "ENS" OR v1.platform == "ens"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS"
WHERE v2.platform == "ENS" OR v2.platform == "ens"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);

tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
Expand All @@ -486,7 +486,7 @@ CREATE OR REPLACE QUERY find_expand_identity(STRING platform, STRING identity) F
SetAccum<Address> @owner_address;
SetAccum<Address> @resolve_address;

ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "sns"];
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns"];
IF @@domainSystems.contains(platform) == TRUE THEN
tmp = SELECT domain FROM seed:domain-((<Hold_Identity):e)-Identities:owner
ACCUM domain.@owner_address += Address(owner.platform, owner.identity);
Expand Down Expand Up @@ -523,7 +523,7 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
POST-ACCUM @@minUpdateTime += MinUpdatedTimeTuple(tgt.updated_nanosecond, tgt.id);
graph_id = @@minUpdateTime.id;

ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "sns"];
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns"];

IF reverse_flag == 1 THEN
vset = SELECT v FROM Identities:v-((PartOfIdentitiesGraph>):e)-identities_graph
Expand All @@ -534,21 +534,21 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS" AND i.platform != "sns"
WHERE i.platform != "ENS" AND i.platform != "ens" AND i.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS" AND v2.platform != "sns"
WHERE v2.platform != "ENS" AND v2.platform != "ens" AND v2.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS" OR v1.platform != "sns"
WHERE v1.platform == "ENS" OR v1.platform == "ens" OR v1.platform != "sns"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS" OR v2.platform == "sns"
WHERE v2.platform == "ENS" OR v2.platform == "ens" OR v2.platform == "sns"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);

tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
Expand All @@ -564,21 +564,21 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS" AND i.platform != "sns"
WHERE i.platform != "ENS" AND i.platform != "ens" AND i.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS" AND v2.platform != "sns"
WHERE v2.platform != "ENS" AND v2.platform != "ens" AND v2.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS" OR v1.platform == "sns"
WHERE v1.platform == "ENS" OR v1.platform == "ens" OR v1.platform == "sns"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS" OR v2.platform == "sns"
WHERE v2.platform == "ENS" OR v2.platform == "ens" OR v2.platform == "sns"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);
tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Reverse_Resolve");
Expand All @@ -591,21 +591,21 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS" AND i.platform != "sns"
WHERE i.platform != "ENS" AND i.platform != "ens" AND i.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS" AND v2.platform != "sns"
WHERE v2.platform != "ENS" AND v2.platform != "ens" AND v2.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS" OR v1.platform == "sns"
WHERE v1.platform == "ENS" OR v1.platform == "ens" OR v1.platform == "sns"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS" OR v2.platform == "sns"
WHERE v2.platform == "ENS" OR v2.platform == "ens" OR v2.platform == "sns"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);

tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
Expand All @@ -628,7 +628,7 @@ CREATE OR REPLACE QUERY neighbors(VERTEX<Identities> p, INT depth) FOR GRAPH Soc
ACCUM v.@visited = TRUE, @@edges += pf, @@edges += pw
POST-ACCUM @@vertices += v, @@pool += v;
hold = SELECT v FROM seed-((Hold_Identity>|<Hold_Identity):e)-Identities:v
WHERE v.@visited2 == FALSE AND v.platform != "ENS"
WHERE v.@visited2 == FALSE AND v.platform != "ENS" AND v.platform != "ens" AND v.platform != "sns"
ACCUM v.@visited2 = TRUE, @@edges += e
POST-ACCUM @@vertices += v, @@pool += v;
seed (Identities) = {@@pool};
Expand All @@ -645,7 +645,7 @@ CREATE OR REPLACE QUERY neighbors_with_source_reverse(VERTEX<Identities> p, INT
SetAccum<STRING> @source_list;
SetAccum<EDGE> @@edge_set;
SetAccum<VERTEX<Identities>> @@vertices;
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "sns"];
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns"];

##### Initialization #####
seed (Identities) = {p};
Expand Down Expand Up @@ -676,7 +676,7 @@ CREATE OR REPLACE QUERY neighbors_with_source_reverse(VERTEX<Identities> p, INT

hold = SELECT v
FROM seed:s-((Hold_Identity>|<Hold_Identity):e)-Identities:v
WHERE v.@or_visited2 == false AND (v.platform != "ENS" OR s.platform != "ENS")
WHERE v.@or_visited2 == false AND (v.platform != "ENS" AND v.platform != "ens" AND s.platform != "ENS" AND s.platform != "ens")
ACCUM
v.@min_dis += s.@min_dis + 1,
v.@path_list = s.@path_list + [v],
Expand All @@ -695,7 +695,7 @@ CREATE OR REPLACE QUERY neighbors_with_source_reverse(VERTEX<Identities> p, INT
ACCUM start.@reverse += true;

address2 = SELECT addr FROM ResultSet:addr-((Reverse_Resolve_Contract>):r)-Contracts:c
WHERE r.system == "ENS"
WHERE r.system == "ENS" OR r.system == "ens" OR r.system == "sns"
ACCUM addr.@reverse += true;

IF reverse_flag == 0 THEN
Expand Down Expand Up @@ -861,7 +861,7 @@ CREATE OR REPLACE QUERY domain2(STRING name, STRING system) FOR GRAPH SocialGrap
EDGE hold;
EDGE reverse_edge;
OrAccum @@reverse;
IF system == "ENS" THEN
IF system == "ENS" OR system == "ens" THEN
resolved = SELECT v FROM Contracts:c-((Resolve_Contract>):e)-Identities:v
WHERE e.system == system AND e.name == name
ACCUM
Expand Down Expand Up @@ -898,7 +898,7 @@ CREATE OR REPLACE QUERY domain2(STRING name, STRING system) FOR GRAPH SocialGrap
CREATE OR REPLACE QUERY domain(STRING name, STRING system) FOR GRAPH SocialGraph {
EDGE record;
EDGE hold;
IF system == "ENS" THEN
IF system == "ENS" OR system == "ens" THEN
resolved = SELECT v FROM Contracts:c-((Resolve_Contract>):e)-Identities:v
WHERE e.system == system AND e.name == name
ACCUM
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tigergraphql/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl IdentityQuery {
) -> Result<Option<ExpandIdentityRecord>> {
let client = make_http_client();

let platform: Platform = platform.parse()?;
let platform: Platform = platform.to_lowercase().parse()?;

let target = match platform {
Platform::ENS => Target::NFT(
Expand Down
24 changes: 21 additions & 3 deletions src/upstream/rss3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,28 @@ async fn save_item(p: ResultItem) -> Result<TargetProcessedList, Error> {
{
return Ok(vec![]);
}
let mut nft_category = ContractCategory::Unknown;
let standard = real_action.metadata.standard.clone();
if let Some(standard) = standard {
if standard == "ERC-721".to_string() {
nft_category = ContractCategory::ERC721;
} else if standard == "ERC-1155".to_string() {
nft_category = ContractCategory::ERC1155;
}
}

let mut nft_category =
ContractCategory::from_str(real_action.metadata.standard.as_ref().unwrap().as_str())
.unwrap_or_default();
// let mut nft_category = ContractCategory::from_str(
// real_action
// .metadata
// .standard
// .as_ref()
// .unwrap()
// .to_lowercase()
// .as_str(),
// )
// .unwrap_or_default();
println!("{:?}", real_action.metadata.standard);
println!("{:?}", nft_category.to_string());

if real_action.tag_type == "poap".to_string() {
nft_category = ContractCategory::POAP;
Expand Down
13 changes: 12 additions & 1 deletion src/upstream/space_id/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[cfg(test)]
mod tests {
use crate::error::Error;
use crate::upstream::space_id::{get_address, get_name};
use crate::upstream::space_id::{get_address, get_name, SpaceId};
use crate::upstream::{Fetcher, Platform, Target};

#[tokio::test]
async fn test_get_address() -> Result<(), Error> {
Expand All @@ -20,4 +21,14 @@ mod tests {
println!("name: {:?}", name);
Ok(())
}

#[tokio::test]
async fn test_fetch() -> Result<(), Error> {
let target = Target::Identity(
Platform::Ethereum,
"0x934b510d4c9103e6a87aef13b816fb080286d649".to_lowercase(),
);
let _ = SpaceId::fetch(&target).await?;
Ok(())
}
}
30 changes: 15 additions & 15 deletions src/upstream/types/contract_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ use strum_macros::{Display, EnumIter, EnumString};
Hash,
)]
pub enum ContractCategory {
#[strum(serialize = "ENS")]
#[serde(rename = "ENS")]
#[graphql(name = "ENS")]
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
#[graphql(name = "ens")]
ENS,

#[strum(serialize = "ERC721", serialize = "ERC-721")]
#[serde(rename = "ERC721")]
#[graphql(name = "ERC721")]
#[strum(serialize = "erc721")]
#[serde(rename = "erc721")]
#[graphql(name = "erc721")]
ERC721,

#[strum(serialize = "ERC1155", serialize = "ERC-1155")]
#[serde(rename = "ERC1155")]
#[graphql(name = "ERC1155")]
#[strum(serialize = "erc1155")]
#[serde(rename = "erc1155")]
#[graphql(name = "erc1155")]
ERC1155,

#[strum(serialize = "POAP")]
#[serde(rename = "POAP")]
#[graphql(name = "POAP")]
#[strum(serialize = "poap")]
#[serde(rename = "poap")]
#[graphql(name = "poap")]
POAP,

#[strum(serialize = "SNS")]
#[serde(rename = "SNS")]
#[graphql(name = "SNS")]
#[strum(serialize = "sns")]
#[serde(rename = "sns")]
#[graphql(name = "sns")]
SNS,

#[default]
Expand Down
6 changes: 3 additions & 3 deletions src/upstream/types/domain_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use strum_macros::{Display, EnumIter, EnumString};
pub enum DomainNameSystem {
/// ENS name system on the ETH chain.
/// https://ens.domains
#[strum(serialize = "ENS")]
#[serde(rename = "ENS")]
#[graphql(name = "ENS")]
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
#[graphql(name = "ens")]
ENS,

/// https://www.sns.id: Solana Name Service
Expand Down
6 changes: 3 additions & 3 deletions src/upstream/types/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ pub enum Platform {
HackerNews,

/// ENS
#[strum(serialize = "ENS")]
#[serde(rename = "ENS")]
#[graphql(name = "ENS")]
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
#[graphql(name = "ens")]
ENS,

/// https://www.sns.id: Solana Name Service
Expand Down

0 comments on commit 39a3c17

Please sign in to comment.