Migrate database updates to use TimeEntrys over ReportRows

This commit is contained in:
2024-03-03 20:35:53 +00:00
parent 62657f2bdd
commit 7759632848
6 changed files with 153 additions and 125 deletions
+14 -1
View File
@@ -40,6 +40,10 @@ impl TogglApiClient {
}
}
pub fn workspace_id(&self) -> i64 {
self.workspace_id.parse().unwrap()
}
pub async fn check_health(&self) -> bool {
true
}
@@ -100,6 +104,15 @@ impl TogglApiClient {
Ok(clients)
}
pub async fn fetch_recent_time_entries(&self) -> crate::Result<Vec<TimeEntry>> {
let url = format!("{base_url}/me/time_entries", base_url = self.base_url);
Ok(self.make_request(self.client.get(url))
.await?
.json::<Vec<TimeEntry>>()
.await?)
}
pub async fn fetch_time_entries_modified_since(
&self,
date_time: DateTime<Utc>,
@@ -119,7 +132,7 @@ impl TogglApiClient {
pub async fn fetch_time_entries_in_range(
&self,
(start, end): (DateTime<Utc>, DateTime<Utc>),
start: DateTime<Utc>, end: DateTime<Utc>,
) -> crate::Result<Vec<TimeEntry>> {
let url = format!("{base_url}/me/time_entries", base_url = self.base_url);
+1 -1
View File
@@ -35,7 +35,7 @@ pub struct TimeEntry {
pub id: i64,
pub workspace_id: i64,
pub project_id: Option<i64>,
pub task_id: Option<Value>,
pub task_id: Option<i64>,
pub billable: bool,
pub start: DateTime<Utc>,
pub stop: Option<DateTime<Utc>>,