Skip to content
Merged
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
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ serde = { version = "*", features = ["derive"] }
serde_json = { version = "*", default-features = false, features = ["std"] }
serde_yaml = { version = "*", default-features = false }
quick-xml = { version = "*", features = ["serialize"] }
urlencoding = { version = "*", default-features = false }
percent-encoding = { version = "*", default-features = false }
regex = { version = "*", default-features = false, features = ["std"] }
# CLI
Expand Down
16 changes: 4 additions & 12 deletions src/interpreter/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use flamelens::ui;
use ratatui::Terminal;
use ratatui::backend::CrosstermBackend;
use std::io;
use urlencoding::encode;

pub fn show(block: Columns) -> AppResult<()> {
let data = block
Expand Down Expand Up @@ -72,11 +71,7 @@ pub fn show(block: Columns) -> AppResult<()> {
Ok(())
}

pub async fn open_in_speedscope(
block: Columns,
pastila_clickhouse_host: &str,
pastila_url: &str,
) -> Result<()> {
pub async fn share(block: Columns, pastila_clickhouse_host: &str, pastila_url: &str) -> Result<()> {
let data = block
.rows()
.map(|x| {
Expand All @@ -93,12 +88,9 @@ pub async fn open_in_speedscope(
return Err(Error::msg("Flamegraph is empty"));
}

let pastila_url = pastila::upload(&data, pastila_clickhouse_host, pastila_url).await?;

let url = format!(
"https://www.speedscope.app/#profileURL={}",
encode(&pastila_url)
);
let pastila_url =
pastila::upload_encrypted(&data, pastila_clickhouse_host, pastila_url).await?;
let url = format!("https://whodidit.you/#profileURL={}", pastila_url);

let mut child = open_url_command(&url)
.spawn()
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ async fn render_flamegraph(
}))
.map_err(|_| anyhow!("Cannot send message to UI"))?;
} else {
flamegraph::open_in_speedscope(block, &pastila_clickhouse_host, &pastila_url).await?;
flamegraph::share(block, &pastila_clickhouse_host, &pastila_url).await?;
}
return Ok(());
}
Expand Down
38 changes: 0 additions & 38 deletions src/pastila.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,44 +172,6 @@ async fn get_pastila_client(pastila_clickhouse_host: &str) -> Result<clickhouse_
Ok(client)
}

pub async fn upload(
content: &str,
pastila_clickhouse_host: &str,
pastila_url: &str,
) -> Result<String> {
let fingerprint_hex = get_fingerprint(content);
let hash_hex = calculate_hash(content);

{
let mut client = get_pastila_client(pastila_clickhouse_host).await?;
let block = Block::new()
.column("fingerprint_hex", vec![fingerprint_hex.as_str()])
.column("hash_hex", vec![hash_hex.as_str()])
.column("content", vec![content])
.column("is_encrypted", vec![0_u8]);
client.insert("paste.data", block).await?;
}

log::info!(
"Uploaded {} bytes to {}",
content.len(),
pastila_clickhouse_host
);

let pastila_url = pastila_url.trim_end_matches('/');
let pastila_page_url = format!("{}/?{}/{}", pastila_url, fingerprint_hex, hash_hex);
log::info!("Pastila URL: {}", pastila_page_url);

let select_query = format!(
"SELECT content FROM data_view(fingerprint = '{}', hash = '{}') FORMAT TabSeparatedRaw",
fingerprint_hex, hash_hex
);
let clickhouse_url = format!("{}&query={}", pastila_clickhouse_host, &select_query);
log::info!("Pastila ClickHouse URL: {}", clickhouse_url);

Ok(clickhouse_url)
}

pub async fn upload_encrypted(
content: &str,
pastila_clickhouse_host: &str,
Expand Down
Loading