Add time_entry columns
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::entity::{client, project, time_entry};
|
||||
use crate::toggl_api::types::{Project, Client, ReportRow};
|
||||
use crate::toggl_api::types::{Project, Client, ReportRow, TimeEntry};
|
||||
use sea_orm::sea_query::OnConflict;
|
||||
use sea_orm::{NotSet, Set};
|
||||
|
||||
@@ -32,6 +32,20 @@ impl ReportRow {
|
||||
}
|
||||
}
|
||||
|
||||
impl TimeEntry {
|
||||
pub(crate) fn as_model(&self) -> time_entry::ActiveModel {
|
||||
time_entry::ActiveModel {
|
||||
id: NotSet,
|
||||
toggl_id: Set(self.id),
|
||||
description: Set(self.description.clone()),
|
||||
project_id: Set(self.project_id),
|
||||
start: Set(self.start.clone().fixed_offset()),
|
||||
stop: Set(self.stop.unwrap().fixed_offset()),
|
||||
raw_json: Set(serde_json::to_value(self).unwrap()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn as_model(&self) -> client::ActiveModel {
|
||||
client::ActiveModel {
|
||||
@@ -70,7 +84,7 @@ impl Project {
|
||||
color: Set(self.color.clone()),
|
||||
server_created_at: Set(self.created_at.clone().fixed_offset()),
|
||||
server_updated_at: Set(self.at.clone().fixed_offset()),
|
||||
server_deleted_at: Set(self.server_deleted_at.clone().fixed_offset()),
|
||||
server_deleted_at: Set(self.server_deleted_at.map(|dt| dt.fixed_offset())),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ pub struct Model {
|
||||
pub stop: DateTimeWithTimeZone,
|
||||
#[sea_orm(column_type = "JsonBinary")]
|
||||
pub raw_json: Json,
|
||||
#[sea_orm(column_type = "JsonBinary")]
|
||||
pub tags: Json,
|
||||
pub server_updated_at: DateTimeWithTimeZone,
|
||||
pub server_deleted_at: Option<DateTimeWithTimeZone>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
||||
@@ -37,14 +37,14 @@ pub struct TimeEntry {
|
||||
pub project_id: Option<i64>,
|
||||
pub task_id: Option<Value>,
|
||||
pub billable: bool,
|
||||
pub start: String,
|
||||
pub stop: Option<String>,
|
||||
pub start: DateTime<Utc>,
|
||||
pub stop: Option<DateTime<Utc>>,
|
||||
pub duration: i64,
|
||||
pub description: String,
|
||||
pub tags: Vec<String>,
|
||||
pub tag_ids: Vec<i64>,
|
||||
pub at: String,
|
||||
pub server_deleted_at: Option<String>,
|
||||
pub at: DateTime<Utc>,
|
||||
pub server_deleted_at: Option<DateTime<Utc>>,
|
||||
pub user_id: i64,
|
||||
|
||||
// Ignored fields
|
||||
|
||||
Reference in New Issue
Block a user