Stash changes
This commit is contained in:
parent
f08397ab15
commit
ac049beff7
3
.env
3
.env
@ -1 +1,4 @@
|
|||||||
DATABASE_URL=postgres://postgres@localhost:5432/toggl_portal
|
DATABASE_URL=postgres://postgres@localhost:5432/toggl_portal
|
||||||
|
TOGGL_API_TOKEN=237918c4e008f5aeefe886c9112ab560
|
||||||
|
TOGGL_WORKSPACE_ID=2837131
|
||||||
|
WORKSPACE_ID=${TOGGL_WORKSPACE_ID}
|
||||||
|
|||||||
10
GRAFTING.md
Normal file
10
GRAFTING.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
- Possible sources
|
||||||
|
- report
|
||||||
|
- me/time_enries
|
||||||
|
- This will need to filter by `workspace_id` if don't want to deal with multiple workspaces.
|
||||||
|
- csv
|
||||||
|
- This can give us a complete picture of the time entries, but it lacks an `id` field so cannot be easily updated
|
||||||
|
- The first two contain `at` which is when the time entry was last updated, useful for grafting
|
||||||
|
- `me/time_entries` can get anything **updated** since a given time
|
||||||
|
- This is incredibly useful for updating the time entries
|
||||||
|
- Most historic time entries are not ever changed so a csv of say, 2023 is probably alwasy going to be valid
|
||||||
@ -10,8 +10,6 @@ use axum::http::StatusCode;
|
|||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use axum::routing::{get, post};
|
use axum::routing::{get, post};
|
||||||
use axum::{Extension, Json, Router};
|
use axum::{Extension, Json, Router};
|
||||||
use base64::engine::general_purpose::STANDARD;
|
|
||||||
use base64::Engine;
|
|
||||||
use utils::{shutdown_signal, Result};
|
use utils::{shutdown_signal, Result};
|
||||||
use chrono::{NaiveDate, NaiveTime};
|
use chrono::{NaiveDate, NaiveTime};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
@ -229,14 +227,16 @@ async fn main() -> Result<()> {
|
|||||||
let config = Config::parse();
|
let config = Config::parse();
|
||||||
let toggl_client = TogglApiClient::new(
|
let toggl_client = TogglApiClient::new(
|
||||||
&config.workspace_id.to_string(),
|
&config.workspace_id.to_string(),
|
||||||
&STANDARD.encode(&format!("{}:api_token", config.toggl_api_token)),
|
&config.toggl_api_token,
|
||||||
);
|
);
|
||||||
|
|
||||||
let db = sea_orm::Database::connect(config.database_url)
|
let db = sea_orm::Database::connect(config.database_url)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Migrator::up(&db, None).await.expect("Failed to migrate");
|
Migrator::up(&db, None)
|
||||||
|
.await
|
||||||
|
.expect("Failed to migrate");
|
||||||
|
|
||||||
tokio::spawn(poll::poll_job(
|
tokio::spawn(poll::poll_job(
|
||||||
toggl_client.clone(),
|
toggl_client.clone(),
|
||||||
|
|||||||
@ -2,7 +2,10 @@ use reqwest::Client;
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use base64::Engine;
|
||||||
|
use base64::engine::general_purpose::STANDARD;
|
||||||
use hyper::HeaderMap;
|
use hyper::HeaderMap;
|
||||||
|
use migration::cli::Cli;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
use tracing::log::debug;
|
use tracing::log::debug;
|
||||||
use crate::toggl_api::types::{Current, Project, ProjectClient, ReportEntry, TogglQuery};
|
use crate::toggl_api::types::{Current, Project, ProjectClient, ReportEntry, TogglQuery};
|
||||||
@ -22,7 +25,9 @@ impl TogglApiClient {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(workspace_id: &str, toggl_auth: &str) -> Self {
|
pub fn new(workspace_id: &str, api_token: &str) -> Self {
|
||||||
|
let toggl_auth = &STANDARD.encode(&format!("{}:api_token", api_token));
|
||||||
|
|
||||||
let client = Client::builder()
|
let client = Client::builder()
|
||||||
.default_headers(Self::default_headers(toggl_auth))
|
.default_headers(Self::default_headers(toggl_auth))
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user