Skip to content

Commit

Permalink
update TTA call params
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreLeGuen committed Sep 20, 2023
1 parent 61a5b6c commit 4354341
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ async fn main() -> Result<()> {
Err(e) => warn!("Failed to load .env file: {}", e),
}

let filter = match option_env!("LOG_LEVEL") {
Some(level) => EnvFilter::new(level),
None => EnvFilter::new("info"),
};

init_tracing()?;

let app = router().await?;
Expand Down
18 changes: 12 additions & 6 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,23 @@ <h1>NEAR transaction report</h1>
<script>
const TTA_URL = "https://tta-api.onrender.com";

function handleDownloadClick() {
const handleDownloadClick = async () => {
const downloadButton = document.getElementById("downloadButton");
downloadButton.disabled = true;
downloadButton.innerText = "Loading, time to grab a coffee...";

const startDate = document.getElementById("startDate").value;
const endDate = document.getElementById("endDate").value;
const accountIds = document.getElementById("accountIds").value.trim().split(/[\n,]/).join(",");
const includeBalances = document.getElementById("includeBalances").checked;

const url = `${TTA_URL}/tta?start_date=${startDate}&end_date=${endDate}&accounts=${accountIds}&include_balances=${includeBalances}`;
// Use toISOString directly without substring for full "YYYY-MM-DDTHH:MM:SS.ZZZZ" format
const start = new Date(startDate + "T00:00:00Z").toISOString();
const end = new Date(endDate + "T00:00:00Z").toISOString();

// Split the accountIds by newline character
const accountIdsArray = accountIds.replaceAll(" ", "").split("\n");
const commaSeparatedAccountIds = accountIdsArray.join(",");

const url =
`${TTA_URL}/tta?start_date=${start}&end_date=${end}&accounts=${commaSeparatedAccountIds}` +
`&include_balances=${includeBalances.toString()}`;

fetch(url, { method: "GET" }).then(response => {
if (response.ok) {
Expand Down

0 comments on commit 4354341

Please sign in to comment.