Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions devprofiler/src/core/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,24 @@ pub async fn process_review(message_data: &Vec<u8>) {
fn get_tasks(message_data: &Vec<u8>) -> Option<Review>{
match serde_json::from_slice::<Value>(&message_data) {
Ok(data) => {
let repo_provider = data["repository_provider"].to_string().trim_matches('"').to_string();
let repo_name = data["event_payload"]["repository"]["name"].to_string().trim_matches('"').to_string();
println!("data == {:?}", &data["eventPayload"]["repository"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to keep the println?

let repo_provider = data["repositoryProvider"].to_string().trim_matches('"').to_string();
let repo_name = data["eventPayload"]["repository"]["name"].to_string().trim_matches('"').to_string();
println!("repo NAME == {}", &repo_name);
let workspace_name = data["event_payload"]["repository"]["workspace"]["slug"].to_string().trim_matches('"').to_string();
let workspace_name = data["eventPayload"]["repository"]["workspace"]["slug"].to_string().trim_matches('"').to_string();
let (clone_url, clone_dir) = get_clone_url_clone_dir(&repo_provider, &workspace_name, &repo_name);
let pr_id = data["event_payload"]["pullrequest"]["id"].to_string().trim_matches('"').to_string();
let pr_id = data["eventPayload"]["pullrequest"]["id"].to_string().trim_matches('"').to_string();
let review = Review::new(
data["event_payload"]["pullrequest"]["destination"]["commit"]["hash"].to_string().replace("\"", ""),
data["event_payload"]["pullrequest"]["source"]["commit"]["hash"].to_string().replace("\"", ""),
data["eventPayload"]["pullrequest"]["destination"]["commit"]["hash"].to_string().replace("\"", ""),
data["eventPayload"]["pullrequest"]["source"]["commit"]["hash"].to_string().replace("\"", ""),
pr_id.clone(),
repo_name.clone(),
workspace_name.clone(),
repo_provider.clone(),
format!("bitbucket/{}/{}/{}", &workspace_name, &repo_name, &pr_id),
clone_dir,
clone_url,
data["event_payload"]["pullrequest"]["author"]["account_id"].to_string().replace("\"", ""),
data["eventPayload"]["pullrequest"]["author"]["account_id"].to_string().replace("\"", ""),
);
println!("review = {:?}", &review);
save_review_to_db(&review);
Expand Down
8 changes: 5 additions & 3 deletions devprofiler/src/core/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct SetupInfo {

#[derive(Debug, Deserialize, Serialize, Clone)]
struct PublishRequest {
installation_id: String,
installationId: String,
info: Vec<SetupInfo>,
}

Expand Down Expand Up @@ -77,15 +77,17 @@ pub async fn handle_install_bitbucket(installation_code: &str) {
async fn send_setup_info(setup_info: &Vec<SetupInfo>) {
let installation_id = env::var("INSTALL_ID")
.expect("INSTALL_ID must be set");
println!("install_id = {:?}", &installation_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a part of debugging?

let base_url = env::var("SERVER_URL")
.expect("SERVER_URL must be set");
let body = PublishRequest {
installation_id: installation_id,
installationId: installation_id,
info: setup_info.to_vec(),
};
println!("body = {:?}", &body);
let client = Client::new();
let resp = client
.post(format!("{base_url}/api/rustapp/setup"))
.post(format!("{base_url}/api/rustApp/setup"))
.json(&body)
.send()
.await
Expand Down