Skip to content

Commit b163c83

Browse files
authored
Merge pull request #46 from Mach-34/fix/hash-in-find-degrees
Change phrase_hash to phrase in get-new-degrees
2 parents e4e42da + 8f74ebb commit b163c83

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

crates/grapevine_server/src/mongo.rs

+4-27
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl GrapevineDB {
454454
"localField": "degree_proofs",
455455
"foreignField": "_id",
456456
"as": "userDegreeProofs",
457-
"pipeline": [doc! { "$project": { "degree": 1, "phrase_hash": 1 } }]
457+
"pipeline": [doc! { "$project": { "degree": 1, "phrase": 1 } }]
458458
}
459459
},
460460
// look up the relationships made by this user
@@ -477,7 +477,7 @@ impl GrapevineDB {
477477
"as": "relationshipDegreeProofs",
478478
"pipeline": [
479479
doc! { "$match": { "inactive": { "$ne": true } } },
480-
doc! { "$project": { "degree": 1, "phrase_hash": 1 } }
480+
doc! { "$project": { "degree": 1, "phrase": 1 } }
481481
]
482482
}
483483
},
@@ -487,7 +487,7 @@ impl GrapevineDB {
487487
// find the lowest degree proof in each chain from relationship proofs and reference user proofs in this chain if exists
488488
doc! {
489489
"$group": {
490-
"_id": "$relationshipDegreeProofs.phrase_hash",
490+
"_id": "$relationshipDegreeProofs.phrase",
491491
"originalId": { "$first": "$relationshipDegreeProofs._id" },
492492
"degree": { "$min": "$relationshipDegreeProofs.degree" },
493493
"userProof": {
@@ -496,7 +496,7 @@ impl GrapevineDB {
496496
"$filter": {
497497
"input": "$userDegreeProofs",
498498
"as": "userProof",
499-
"cond": { "$eq": ["$$userProof.phrase_hash", "$relationshipDegreeProofs.phrase_hash"] }
499+
"cond": { "$eq": ["$$userProof.phrase", "$relationshipDegreeProofs.phrase"] }
500500
}
501501
}, 0]
502502
}
@@ -1173,29 +1173,6 @@ impl GrapevineDB {
11731173
}
11741174
}
11751175

1176-
/**
1177-
* Get chain of degree proofs linked to a phrase
1178-
*
1179-
* @param phrase_hash - hash of the phrase linking the proof chain together
1180-
*/
1181-
pub async fn get_proof_chain(&self, phrase_hash: &str) -> Vec<DegreeProof> {
1182-
let mut proofs: Vec<DegreeProof> = vec![];
1183-
let query = doc! { "phrase_hash": phrase_hash };
1184-
let projection = doc! { "_id": 1, "degree": 1 };
1185-
let find_options = FindOptions::builder().projection(projection).build();
1186-
let mut cursor = self.degree_proofs.find(query, find_options).await.unwrap();
1187-
1188-
while let Some(result) = cursor.next().await {
1189-
match result {
1190-
Ok(proof) => {
1191-
proofs.push(proof);
1192-
}
1193-
Err(e) => println!("Error: {:?}", e),
1194-
}
1195-
}
1196-
proofs
1197-
}
1198-
11991176
/**
12001177
* Check to see if degree already exists between two accounts
12011178
*

crates/grapevine_server/src/routes/proof.rs

-20
Original file line numberDiff line numberDiff line change
@@ -366,26 +366,6 @@ pub async fn get_proof_with_params(
366366
}
367367
}
368368

369-
/**
370-
* Return a list of all proofs linked to a given phrase hash
371-
*
372-
*
373-
* @param phrase hash - the hash of the phrase creating the proof chain
374-
* @return - a vector of stringified OIDs of proofs within the given chain
375-
* @return status:
376-
* - 200 if successful retrieval
377-
* - 401 if signature mismatch or nonce mismatch
378-
* - 404 if user not found
379-
* - 500 if db fails or other unknown issue
380-
*/
381-
#[get("/chain/<phrase_hash>")]
382-
pub async fn get_proof_chain(
383-
phrase_hash: String,
384-
db: &State<GrapevineDB>,
385-
) -> Result<Json<Vec<DegreeProof>>, Status> {
386-
Ok(Json(db.get_proof_chain(&phrase_hash).await))
387-
}
388-
389369
/**
390370
* Get all created phrases
391371
*/

0 commit comments

Comments
 (0)