From 6d05973017f9c771b3dce085be704d5a3e47ccc6 Mon Sep 17 00:00:00 2001 From: Maksim Ryndin Date: Wed, 15 May 2024 12:01:02 +0000 Subject: [PATCH] link to the spreadsheet at usage check message --- src/configuration.rs | 5 +++-- src/google/spreadsheet.rs | 11 +++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/configuration.rs b/src/configuration.rs index 3fbd541..2dea1c1 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -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; @@ -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"); } diff --git a/src/google/spreadsheet.rs b/src/google/spreadsheet.rs index 1ceff1e..719dd1b 100644 --- a/src/google/spreadsheet.rs +++ b/src/google/spreadsheet.rs @@ -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; @@ -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(