Skip to content

Commit

Permalink
[!] add edge_type for identityConnection and do some cutoff about e…
Browse files Browse the repository at this point in the history
…dges
  • Loading branch information
ZhongFuze committed Feb 1, 2024
1 parent 818a8ca commit 5ad3665
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/config/tdb/migrations/LoadingJob_SocialGraph.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ CREATE OR REPLACE QUERY find_identity_graph_by_vertex(VERTEX<Identities> p) FOR


CREATE OR REPLACE QUERY query_identity_graph_by_ids(SET<STRING> ids) FOR GRAPH SocialGraph {
TYPEDEF TUPLE< VERTEX source_v, VERTEX target_v, STRING data_source > IdentityConnection;
TYPEDEF TUPLE< VERTEX source_v, VERTEX target_v, STRING data_source, STRING edge_type > IdentityConnection;
SetAccum<IdentityConnection> @@edges;
SetAccum<VERTEX> @@hyper_vset;
@@hyper_vset = to_vertex_set(ids, "IdentitiesGraph");
Expand All @@ -341,10 +341,26 @@ CREATE OR REPLACE QUERY query_identity_graph_by_ids(SET<STRING> ids) FOR GRAPH S
@@edges.clear();
hyper_v = {hv};
vset = SELECT v FROM Identities:v-((PartOfIdentitiesGraph>):e)-hyper_v;
tmp1 = SELECT v1 FROM vset:v1-((Proof_Forward>|Proof_Backward>|Hold_Identity>|Resolve>|Reverse_Resolve>):e1)-vset:v2
ACCUM @@edges += IdentityConnection(v1, v2, e1.source);
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward|<Hold_Identity|<Resolve|<Reverse_Resolve):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source);

tmp1 = SELECT v1 FROM vset:v1-((Proof_Forward>|Proof_Backward>):e1)-vset:v2
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Proof");
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp3 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform == "ens"
ACCUM
IF v1 == v2 THEN
@@edges += IdentityConnection(v1, i, e1.source, "Hold")
ELSE
@@edges += IdentityConnection(v1, i, e1.source, "Hold"),
@@edges += IdentityConnection(i, v2, e2.source, "Resolve")
END;
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ens"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold");

tmp5 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Reverse_Resolve");

PRINT hv as graph_id, vset as vertices, @@edges as edges;
END;
Expand Down
5 changes: 5 additions & 0 deletions src/controller/tigergraphql/identity_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ impl IdentityGraph {

#[Object]
impl IdentityConnection {
/// Returns edge type connects start node and end node.
async fn edge_type(&self) -> String {
self.edge_type.clone()
}

/// Returns data sources from upstreams supported by RelationService.
async fn data_source(&self) -> DataSource {
self.data_source
Expand Down
1 change: 1 addition & 0 deletions src/tigergraph/vertex/identity_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct IdentityGraphResponse {

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IdentityConnection {
pub edge_type: String,
pub data_source: DataSource,
#[serde(rename = "source_v")]
pub source: String,
Expand Down

0 comments on commit 5ad3665

Please sign in to comment.