Skip to content

Commit

Permalink
link to the spreadsheet at usage check message
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimryndin committed May 15, 2024
1 parent 3400e64 commit 6d05973
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::str::FromStr;
use url::{Host, Url};

pub const APP_NAME: &str = "GORAL";
pub const GOOGLE_SHEET_BASE: &str = "https://docs.google.com/spreadsheets/d/";

pub(crate) fn ceiled_division(divisable: u16, divisor: u16) -> u16 {
let quotient = divisable / divisor;
Expand Down Expand Up @@ -167,8 +168,8 @@ impl Configuration {
if total > 100.0 {
write!(
&mut message,
"current usage limits sum up to {}% for spreadsheet `{}`,",
total, spreadsheet_id
"current usage limits sum up to {}% for [spreadsheet]({}{}),",
total, GOOGLE_SHEET_BASE, spreadsheet_id
)
.expect("assert: can write to string");
}
Expand Down
11 changes: 3 additions & 8 deletions src/google/spreadsheet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::configuration::GOOGLE_SHEET_BASE;
use crate::google::sheet::{CleanupSheet, Rows, Sheet, SheetId, UpdateSheet, VirtualSheet};
use crate::google::Metadata;
use crate::storage::StorageError;
Expand Down Expand Up @@ -241,17 +242,11 @@ impl SpreadsheetAPI {
}

pub(crate) fn sheet_url(&self, spreadsheet_id: &str, sheet_id: SheetId) -> String {
format!(
"https://docs.google.com/spreadsheets/d/{}#gid={}",
spreadsheet_id, sheet_id
)
format!("{GOOGLE_SHEET_BASE}{spreadsheet_id}#gid={sheet_id}")
}

pub(crate) fn spreadsheet_baseurl(&self, spreadsheet_id: &str) -> String {
format!(
"https://docs.google.com/spreadsheets/d/{}#gid=",
spreadsheet_id
)
format!("{GOOGLE_SHEET_BASE}{spreadsheet_id}#gid=")
}

pub(crate) async fn sheets_filtered_by_metadata(
Expand Down

0 comments on commit 6d05973

Please sign in to comment.