Skip to content

Commit e84495c

Browse files
committed
fix: date_time conversions
1 parent a13f389 commit e84495c

File tree

10 files changed

+73
-61
lines changed

10 files changed

+73
-61
lines changed

migrations/20221228013635_init.sql

13.7 KB
Binary file not shown.

sqlx-data.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
{
4747
"name": "start_date",
4848
"ordinal": 8,
49-
"type_info": "Timestamp"
49+
"type_info": "Timestamptz"
5050
},
5151
{
5252
"name": "due_date",
5353
"ordinal": 9,
54-
"type_info": "Timestamp"
54+
"type_info": "Timestamptz"
5555
}
5656
],
5757
"nullable": [
@@ -73,8 +73,8 @@
7373
"Uuid",
7474
"Text",
7575
"Uuid",
76-
"Timestamp",
77-
"Timestamp",
76+
"Timestamptz",
77+
"Timestamptz",
7878
"Uuid"
7979
]
8080
}
@@ -137,12 +137,12 @@
137137
{
138138
"name": "start_date",
139139
"ordinal": 10,
140-
"type_info": "Timestamp"
140+
"type_info": "Timestamptz"
141141
},
142142
{
143143
"name": "due_date",
144144
"ordinal": 11,
145-
"type_info": "Timestamp"
145+
"type_info": "Timestamptz"
146146
}
147147
],
148148
"nullable": [
@@ -651,12 +651,12 @@
651651
{
652652
"name": "start_date",
653653
"ordinal": 8,
654-
"type_info": "Timestamp"
654+
"type_info": "Timestamptz"
655655
},
656656
{
657657
"name": "due_date",
658658
"ordinal": 9,
659-
"type_info": "Timestamp"
659+
"type_info": "Timestamptz"
660660
}
661661
],
662662
"nullable": [
@@ -829,12 +829,12 @@
829829
{
830830
"name": "start_date",
831831
"ordinal": 8,
832-
"type_info": "Timestamp"
832+
"type_info": "Timestamptz"
833833
},
834834
{
835835
"name": "due_date",
836836
"ordinal": 9,
837-
"type_info": "Timestamp"
837+
"type_info": "Timestamptz"
838838
}
839839
],
840840
"nullable": [
@@ -1135,12 +1135,12 @@
11351135
{
11361136
"name": "start_date",
11371137
"ordinal": 8,
1138-
"type_info": "Timestamp"
1138+
"type_info": "Timestamptz"
11391139
},
11401140
{
11411141
"name": "due_date",
11421142
"ordinal": 9,
1143-
"type_info": "Timestamp"
1143+
"type_info": "Timestamptz"
11441144
}
11451145
],
11461146
"nullable": [
@@ -1588,12 +1588,12 @@
15881588
{
15891589
"name": "start_date",
15901590
"ordinal": 10,
1591-
"type_info": "Timestamp"
1591+
"type_info": "Timestamptz"
15921592
},
15931593
{
15941594
"name": "due_date",
15951595
"ordinal": 11,
1596-
"type_info": "Timestamp"
1596+
"type_info": "Timestamptz"
15971597
}
15981598
],
15991599
"nullable": [
@@ -1980,12 +1980,12 @@
19801980
{
19811981
"name": "start_date",
19821982
"ordinal": 8,
1983-
"type_info": "Timestamp"
1983+
"type_info": "Timestamptz"
19841984
},
19851985
{
19861986
"name": "due_date",
19871987
"ordinal": 9,
1988-
"type_info": "Timestamp"
1988+
"type_info": "Timestamptz"
19891989
}
19901990
],
19911991
"nullable": [
@@ -2250,12 +2250,12 @@
22502250
{
22512251
"name": "start_date",
22522252
"ordinal": 8,
2253-
"type_info": "Timestamp"
2253+
"type_info": "Timestamptz"
22542254
},
22552255
{
22562256
"name": "due_date",
22572257
"ordinal": 9,
2258-
"type_info": "Timestamp"
2258+
"type_info": "Timestamptz"
22592259
}
22602260
],
22612261
"nullable": [
@@ -2277,8 +2277,8 @@
22772277
"Uuid",
22782278
"Text",
22792279
"Uuid",
2280-
"Timestamp",
2281-
"Timestamp"
2280+
"Timestamptz",
2281+
"Timestamptz"
22822282
]
22832283
}
22842284
},
@@ -2943,12 +2943,12 @@
29432943
{
29442944
"name": "start_date",
29452945
"ordinal": 8,
2946-
"type_info": "Timestamp"
2946+
"type_info": "Timestamptz"
29472947
},
29482948
{
29492949
"name": "due_date",
29502950
"ordinal": 9,
2951-
"type_info": "Timestamp"
2951+
"type_info": "Timestamptz"
29522952
}
29532953
],
29542954
"nullable": [

src/graphql/mutation.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::process::id;
2-
31
use async_graphql::{Context, InputObject, Object};
42
use chrono::{DateTime, Utc};
53
use sqlx;
@@ -521,8 +519,8 @@ impl MutationRoot {
521519
owner_id,
522520
description,
523521
lead_id,
524-
DateTimeBridge::from_primitive_to_date_time(start_date),
525-
DateTimeBridge::from_primitive_to_date_time(due_date),
522+
start_date.map(|d| DateTimeBridge::from_date_time(d)),
523+
due_date.map(|d| DateTimeBridge::from_date_time(d)),
526524
)
527525
.fetch_one(&plexo_engine.pool).await.unwrap();
528526

@@ -575,10 +573,10 @@ impl MutationRoot {
575573
lead_id: project.lead_id,
576574
start_date: project
577575
.start_date
578-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
576+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
579577
due_date: project
580578
.due_date
581-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
579+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
582580
}
583581
}
584582

@@ -612,8 +610,8 @@ impl MutationRoot {
612610
owner_id,
613611
description,
614612
lead_id,
615-
DateTimeBridge::from_primitive_to_date_time(start_date),
616-
DateTimeBridge::from_primitive_to_date_time(due_date),
613+
start_date.map(|d| DateTimeBridge::from_date_time(d)),
614+
due_date.map(|d| DateTimeBridge::from_date_time(d)),
617615
id,
618616
)
619617
.fetch_one(&plexo_engine.pool).await.unwrap();
@@ -689,10 +687,10 @@ impl MutationRoot {
689687
lead_id: project.lead_id,
690688
start_date: project
691689
.start_date
692-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
690+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
693691
due_date: project
694692
.due_date
695-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
693+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
696694
}
697695
}
698696

@@ -758,10 +756,10 @@ impl MutationRoot {
758756
lead_id: project.lead_id,
759757
start_date: project
760758
.start_date
761-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
759+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
762760
due_date: project
763761
.due_date
764-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
762+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
765763
}
766764
}
767765

src/graphql/query.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ impl QueryRoot {
252252
lead_id: r.lead_id.clone(),
253253
start_date: r
254254
.due_date
255-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
255+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
256256
due_date: r
257257
.due_date
258-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
258+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
259259
})
260260
.collect()
261261
}
@@ -288,10 +288,10 @@ impl QueryRoot {
288288
lead_id: project.lead_id,
289289
start_date: project
290290
.due_date
291-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
291+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
292292
due_date: project
293293
.due_date
294-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
294+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
295295
}
296296
}
297297

src/sdk/labels.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl Label {
8080
pub async fn tasks(&self, ctx: &Context<'_>) -> Vec<Task> {
8181
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
8282
let plexo_engine = ctx.data::<Engine>().unwrap();
83+
println!("token: {}", auth_token);
8384

8485
let loader = ctx.data::<DataLoader<TaskLoader>>().unwrap();
8586

src/sdk/member.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ impl Member {
3636
pub async fn owned_tasks(&self, ctx: &Context<'_>) -> Vec<Task> {
3737
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
3838
let plexo_engine = ctx.data::<Engine>().unwrap();
39+
println!("token: {}", auth_token);
40+
3941
let tasks = sqlx::query!(r#"SELECT * FROM tasks WHERE owner_id = $1"#, &self.id)
4042
.fetch_all(&plexo_engine.pool)
4143
.await
@@ -62,6 +64,8 @@ impl Member {
6264
pub async fn leading_tasks(&self, ctx: &Context<'_>) -> Vec<Task> {
6365
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
6466
let plexo_engine = ctx.data::<Engine>().unwrap();
67+
println!("token: {}", auth_token);
68+
6569
let tasks = sqlx::query!(r#"SELECT * FROM tasks WHERE lead_id = $1"#, &self.id)
6670
.fetch_all(&plexo_engine.pool)
6771
.await
@@ -88,6 +92,8 @@ impl Member {
8892
pub async fn tasks(&self, ctx: &Context<'_>) -> Vec<Task> {
8993
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
9094
let plexo_engine = ctx.data::<Engine>().unwrap();
95+
println!("token: {}", auth_token);
96+
9197
let tasks = sqlx::query!(
9298
r#"
9399
SELECT * FROM tasks_by_assignees JOIN tasks
@@ -120,6 +126,8 @@ impl Member {
120126
pub async fn owned_projects(&self, ctx: &Context<'_>) -> Vec<Project> {
121127
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
122128
let plexo_engine = ctx.data::<Engine>().unwrap();
129+
println!("token: {}", auth_token);
130+
123131
let projects = sqlx::query!(r#"SELECT * FROM projects WHERE owner_id = $1"#, &self.id)
124132
.fetch_all(&plexo_engine.pool)
125133
.await
@@ -137,17 +145,19 @@ impl Member {
137145
lead_id: r.lead_id,
138146
start_date: r
139147
.start_date
140-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
148+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
141149
due_date: r
142150
.due_date
143-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
151+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
144152
})
145153
.collect()
146154
}
147155

148156
pub async fn projects(&self, ctx: &Context<'_>) -> Vec<Project> {
149157
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
150158
let plexo_engine = ctx.data::<Engine>().unwrap();
159+
println!("token: {}", auth_token);
160+
151161
let projects = sqlx::query!(
152162
r#"
153163
SELECT * FROM members_by_projects JOIN projects
@@ -171,17 +181,19 @@ impl Member {
171181
lead_id: r.lead_id,
172182
start_date: r
173183
.start_date
174-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
184+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
175185
due_date: r
176186
.due_date
177-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
187+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
178188
})
179189
.collect()
180190
}
181191

182192
pub async fn teams(&self, ctx: &Context<'_>) -> Vec<Team> {
183193
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
184194
let plexo_engine = ctx.data::<Engine>().unwrap();
195+
println!("token: {}", auth_token);
196+
185197
let teams = sqlx::query!(
186198
r#"
187199
SELECT * FROM members_by_teams JOIN teams

src/sdk/project.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ impl Project {
3737
//cambiado a Option, pq hay un id que no tiene user
3838
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
3939
let plexo_engine = ctx.data::<Engine>().unwrap();
40+
println!("token: {}", auth_token);
4041

4142
let member = sqlx::query!(r#"SELECT * FROM members WHERE id = $1"#, &self.owner_id)
4243
.fetch_one(&plexo_engine.pool)
@@ -61,6 +62,8 @@ impl Project {
6162
pub async fn members(&self, ctx: &Context<'_>) -> Vec<Member> {
6263
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
6364
let plexo_engine = ctx.data::<Engine>().unwrap();
65+
println!("token: {}", auth_token);
66+
6467
let members = sqlx::query!(
6568
r#"
6669
SELECT * FROM members_by_projects JOIN members
@@ -90,6 +93,7 @@ impl Project {
9093
pub async fn tasks(&self, ctx: &Context<'_>) -> Vec<Task> {
9194
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
9295
let plexo_engine = ctx.data::<Engine>().unwrap();
96+
println!("token: {}", auth_token);
9397

9498
let tasks = sqlx::query!(
9599
r#"
@@ -181,6 +185,7 @@ impl Project {
181185
pub async fn teams(&self, ctx: &Context<'_>) -> Vec<Team> {
182186
let auth_token = &ctx.data::<PlexoAuthToken>().unwrap().0;
183187
let plexo_engine = ctx.data::<Engine>().unwrap();
188+
println!("token: {}", auth_token);
184189

185190
let teams = sqlx::query!(
186191
r#"

src/sdk/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ impl Task {
121121
lead_id: project.lead_id,
122122
start_date: project
123123
.start_date
124-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
124+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
125125
due_date: project
126126
.due_date
127-
.map(|d| DateTimeBridge::from_offset_date_time(d.assume_utc())),
127+
.map(|d| DateTimeBridge::from_offset_date_time(d)),
128128
}),
129129
Err(_) => None,
130130
}

0 commit comments

Comments
 (0)