Skip to content

Commit

Permalink
fix the dates
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed Jan 11, 2025
1 parent d927d54 commit 7c3c0a7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rocket = { version = "0.5.0-rc.2", features = ["tls", "json"] }
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.12.2", features = ["json"] }
thiserror = "1.0.58"
diesel = { version = "2.1.6", features = ["postgres", "uuid", "r2d2", "time"] }
diesel = { version = "2.1.6", features = ["postgres", "uuid", "r2d2", "chrono"] }
dotenvy = "0.15"
uuid = { version = "1.8.0", features = ["v4", "serde"] }
diesel_migrations = "2.1.0"
Expand All @@ -32,4 +32,4 @@ semver = "1.0.23"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
tempfile = "3.14.0"
time = { version = "0.3.37", features = ["serde"] }
chrono = { version = "0.4.39", features = ["serde"] }
4 changes: 2 additions & 2 deletions app/src/features/dahboard/components/PackageDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const PackageDashboard: React.FC = () => {
</Typography>
<Typography variant='body2' color='textSecondary' gutterBottom>
{type === 'Just Updated'
? `Updated: ${new Date(pkg.updated_at!).toLocaleString()}`
: `Added: ${new Date(pkg.updated_at!).toLocaleString()}`}
? `Updated: ${new Date(pkg.updatedAt!).toLocaleString()}`
: `Added: ${new Date(pkg.createdAt!).toLocaleString()}`}
</Typography>
<Typography variant='body1' paragraph>
{pkg.description || 'No description available.'}
Expand Down
4 changes: 2 additions & 2 deletions app/src/features/dahboard/hooks/useFetchRecentPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export interface RecentPackage {
name: string;
version: string;
description: string | null;
created_at: string;
updated_at: string;
createdAt: string;
updatedAt: string;
}

export interface RecentPackagesResponse {
Expand Down
11 changes: 6 additions & 5 deletions src/models.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use chrono::{DateTime, Utc};
use diesel::prelude::*;
use diesel::sql_types::{Nullable, Text, Timestamptz};
use diesel::QueryableByName;
use serde::Serialize;
use std::time::SystemTime;
use time::PrimitiveDateTime;
use uuid::Uuid;

#[derive(Queryable, Selectable, Debug, Clone)]
Expand Down Expand Up @@ -98,7 +98,7 @@ pub struct Package {
pub user_owner: Uuid,
pub package_name: String,
pub default_version: Option<Uuid>,
pub created_at: PrimitiveDateTime,
pub created_at: DateTime<Utc>,
}

#[derive(Insertable, Debug)]
Expand All @@ -124,7 +124,7 @@ pub struct PackageVersion {
pub urls: Vec<Option<String>>,
pub readme: Option<String>,
pub license: Option<String>,
pub created_at: PrimitiveDateTime,
pub created_at: DateTime<Utc>,
}

#[derive(Insertable, Debug)]
Expand All @@ -145,6 +145,7 @@ pub struct NewPackageVersion {
}

#[derive(QueryableByName, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct RecentPackage {
#[sql_type = "Text"]
pub name: String, // Corresponds to `p.package_name as name`
Expand All @@ -153,7 +154,7 @@ pub struct RecentPackage {
#[sql_type = "Nullable<Text>"]
pub description: Option<String>, // Corresponds to `pv.package_description as description`, which might be nullable
#[sql_type = "Timestamptz"]
pub created_at: PrimitiveDateTime, // Corresponds to `p.created_at as created_at`
pub created_at: DateTime<Utc>, // Corresponds to `p.created_at as created_at`
#[sql_type = "Timestamptz"]
pub updated_at: PrimitiveDateTime, // Corresponds to `pv.created_at as updated_at`
pub updated_at: DateTime<Utc>, // Corresponds to `pv.created_at as updated_at`
}

0 comments on commit 7c3c0a7

Please sign in to comment.