-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ids are now typed to avoid type confusion Rerun actions
- Loading branch information
Showing
15 changed files
with
103 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod account; | ||
pub mod device; | ||
mod event; | ||
pub mod task; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use derive_more::{From, Into}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, Serialize, Debug, sqlx::Type, PartialEq, Eq, From, Into)] | ||
#[sqlx(transparent)] | ||
pub struct AccountId(i64); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
use derive_more::{From, Into}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::account::AccountId; | ||
|
||
#[derive(Deserialize, Serialize, Debug, sqlx::Type, PartialEq, Eq, From, Into, Clone, Copy)] | ||
#[sqlx(transparent)] | ||
pub struct DeviceId(i64); | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct Device { | ||
pub id: i64, | ||
pub id: DeviceId, | ||
pub effect: f64, | ||
pub account_id: i64, | ||
pub account_id: AccountId, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::time::DateTimeUtc; | ||
use super::{device::DeviceId, time::DateTimeUtc}; | ||
|
||
#[derive(Deserialize, Serialize, Debug, sqlx::Type, PartialEq, Eq)] | ||
#[sqlx(transparent)] | ||
struct EventId(i64); | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct Event { | ||
id: i64, | ||
device_id: i64, | ||
id: EventId, | ||
device_id: DeviceId, | ||
version_nr: i64, | ||
start_time: DateTimeUtc, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::time::{Milliseconds, Timespan}; | ||
use super::{ | ||
device::DeviceId, | ||
time::{Milliseconds, Timespan}, | ||
}; | ||
|
||
use derive_more::{From, Into}; | ||
|
||
#[derive(Deserialize, Serialize, Debug, sqlx::Type, PartialEq, Eq, From, Into, Clone, Copy)] | ||
#[sqlx(transparent)] | ||
pub struct TaskId(i64); | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq)] | ||
pub struct Task { | ||
pub id: i64, | ||
pub id: TaskId, | ||
pub timespan: Timespan, | ||
pub duration: Milliseconds, | ||
pub device_id: i64, | ||
pub device_id: DeviceId, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::data_model::device::DeviceId; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct CreateDeviceRequest { | ||
pub effect: f64, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct DeleteDeviceRequest { | ||
pub id: i64, | ||
pub id: DeviceId, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::data_model::time::{Milliseconds, Timespan}; | ||
use crate::data_model::{ | ||
device::DeviceId, | ||
time::{Milliseconds, Timespan}, | ||
}; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct CreateTaskRequest { | ||
pub timespan: Timespan, | ||
pub duration: Milliseconds, | ||
pub device_id: i64, | ||
pub device_id: DeviceId, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct DeleteTaskRequest { | ||
pub id: i64, | ||
pub id: DeviceId, | ||
} |