mirror of
				https://github.com/nitnelave/lldap.git
				synced 2023-04-12 14:25:13 +00:00 
			
		
		
		
	Migrate datetimes to UTC
This commit is contained in:
		
							parent
							
								
									0cf7b76c1c
								
							
						
					
					
						commit
						d2d7274925
					
				
							
								
								
									
										1
									
								
								app/src/graphql.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								app/src/graphql.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| pub type DateTimeUtc = chrono::DateTime<chrono::Utc>; | ||||
| @ -4,6 +4,7 @@ mod api; | ||||
| mod app; | ||||
| mod cookies; | ||||
| mod create_user; | ||||
| mod graphql; | ||||
| mod login; | ||||
| mod logout; | ||||
| mod user_details; | ||||
|  | ||||
| @ -10,7 +10,7 @@ use yew::services::{fetch::FetchTask, ConsoleService}; | ||||
|     schema_path = "../schema.graphql", | ||||
|     query_path = "queries/list_users.graphql", | ||||
|     response_derives = "Debug", | ||||
|     custom_scalars_module = "chrono" | ||||
|     custom_scalars_module = "crate::graphql" | ||||
| )] | ||||
| pub struct ListUsersQuery; | ||||
| 
 | ||||
| @ -89,7 +89,7 @@ impl Component for UserTable { | ||||
|                                 <td>{&u.display_name.as_ref().unwrap_or(&String::new())}</td> | ||||
|                                 <td>{&u.first_name.as_ref().unwrap_or(&String::new())}</td> | ||||
|                                 <td>{&u.last_name.as_ref().unwrap_or(&String::new())}</td> | ||||
|                                 <td>{&u.creation_date}</td> | ||||
|                                 <td>{&u.creation_date.with_timezone(&chrono::Local)}</td> | ||||
|                             </tr> | ||||
|                         } | ||||
|                     }) | ||||
|  | ||||
| @ -100,7 +100,7 @@ pub struct User { | ||||
|     pub first_name: Option<String>, | ||||
|     pub last_name: Option<String>, | ||||
|     // pub avatar: ?,
 | ||||
|     pub creation_date: chrono::NaiveDateTime, | ||||
|     pub creation_date: chrono::DateTime<chrono::Utc>, | ||||
| } | ||||
| 
 | ||||
| impl Default for User { | ||||
| @ -111,7 +111,7 @@ impl Default for User { | ||||
|             display_name: None, | ||||
|             first_name: None, | ||||
|             last_name: None, | ||||
|             creation_date: chrono::NaiveDateTime::from_timestamp(0, 0), | ||||
|             creation_date: Utc.timestamp(0, 0), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -20,22 +20,22 @@ input RequestFilter { | ||||
|   eq: EqualityConstraint | ||||
| } | ||||
| 
 | ||||
| "DateTime" | ||||
| scalar DateTimeUtc | ||||
| 
 | ||||
| type Query { | ||||
|   apiVersion: String! | ||||
|   user(userId: String!): User! | ||||
|   users(filters: RequestFilter): [User!]! | ||||
| } | ||||
| 
 | ||||
| "NaiveDateTime" | ||||
| scalar NaiveDateTime | ||||
| 
 | ||||
| type User { | ||||
|   id: String! | ||||
|   email: String! | ||||
|   displayName: String | ||||
|   firstName: String | ||||
|   lastName: String | ||||
|   creationDate: NaiveDateTime! | ||||
|   creationDate: DateTimeUtc! | ||||
|   "The groups to which this user belongs." | ||||
|   groups: [Group!]! | ||||
| } | ||||
|  | ||||
| @ -120,7 +120,7 @@ pub async fn init_table(pool: &Pool) -> sqlx::Result<()> { | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use super::*; | ||||
|     use chrono::NaiveDateTime; | ||||
|     use chrono::prelude::*; | ||||
|     use sqlx::{Column, Row}; | ||||
| 
 | ||||
|     #[actix_rt::test] | ||||
| @ -138,8 +138,8 @@ mod tests { | ||||
|         assert_eq!(row.column(0).name(), "display_name"); | ||||
|         assert_eq!(row.get::<String, _>("display_name"), "Bob Bobbersön"); | ||||
|         assert_eq!( | ||||
|             row.get::<NaiveDateTime, _>("creation_date"), | ||||
|             NaiveDateTime::from_timestamp(0, 0) | ||||
|             row.get::<DateTime<Utc>, _>("creation_date"), | ||||
|             Utc.timestamp(0, 0), | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -157,7 +157,7 @@ impl<Handler: BackendHandler + Sync> User<Handler> { | ||||
|         self.user.last_name.as_ref() | ||||
|     } | ||||
| 
 | ||||
|     fn creation_date(&self) -> chrono::NaiveDateTime { | ||||
|     fn creation_date(&self) -> chrono::DateTime<chrono::Utc> { | ||||
|         self.user.creation_date | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -277,7 +277,6 @@ mod tests { | ||||
|     use super::*; | ||||
|     use crate::domain::handler::BindRequest; | ||||
|     use crate::domain::handler::MockTestBackendHandler; | ||||
|     use chrono::NaiveDateTime; | ||||
|     use mockall::predicate::eq; | ||||
|     use tokio; | ||||
| 
 | ||||
| @ -487,7 +486,7 @@ mod tests { | ||||
|                     display_name: Some("Bôb Böbberson".to_string()), | ||||
|                     first_name: Some("Bôb".to_string()), | ||||
|                     last_name: Some("Böbberson".to_string()), | ||||
|                     creation_date: NaiveDateTime::from_timestamp(1_000_000, 0), | ||||
|                     ..Default::default() | ||||
|                 }, | ||||
|                 User { | ||||
|                     user_id: "jim".to_string(), | ||||
| @ -495,7 +494,7 @@ mod tests { | ||||
|                     display_name: Some("Jimminy Cricket".to_string()), | ||||
|                     first_name: Some("Jim".to_string()), | ||||
|                     last_name: Some("Cricket".to_string()), | ||||
|                     creation_date: NaiveDateTime::from_timestamp(1_500_000, 0), | ||||
|                     ..Default::default() | ||||
|                 }, | ||||
|             ]) | ||||
|         }); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Valentin Tolmer
						Valentin Tolmer