You've already forked AstralRinth
forked from didirus/AstralRinth
Switch to time crate, add file sizes (#329)
* Switch to time crate, add file sizes * Update deps, adjust pack format * Run formatter, fix clippy
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use super::ids::*;
|
||||
use super::DatabaseError;
|
||||
use futures::TryStreamExt;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub struct ProjectType {
|
||||
pub id: ProjectTypeId,
|
||||
@@ -19,7 +20,7 @@ pub struct GameVersion {
|
||||
pub id: GameVersionId,
|
||||
pub version: String,
|
||||
pub version_type: String,
|
||||
pub date: chrono::DateTime<chrono::Utc>,
|
||||
pub date: OffsetDateTime,
|
||||
pub major: bool,
|
||||
}
|
||||
|
||||
@@ -469,7 +470,7 @@ impl<'a> LoaderBuilder<'a> {
|
||||
pub struct GameVersionBuilder<'a> {
|
||||
pub version: Option<&'a str>,
|
||||
pub version_type: Option<&'a str>,
|
||||
pub date: Option<&'a chrono::DateTime<chrono::Utc>>,
|
||||
pub date: Option<&'a OffsetDateTime>,
|
||||
}
|
||||
|
||||
impl GameVersion {
|
||||
@@ -689,7 +690,7 @@ impl<'a> GameVersionBuilder<'a> {
|
||||
|
||||
pub fn created(
|
||||
self,
|
||||
created: &'a chrono::DateTime<chrono::Utc>,
|
||||
created: &'a OffsetDateTime,
|
||||
) -> GameVersionBuilder<'a> {
|
||||
Self {
|
||||
date: Some(created),
|
||||
@@ -718,7 +719,7 @@ impl<'a> GameVersionBuilder<'a> {
|
||||
",
|
||||
self.version,
|
||||
self.version_type,
|
||||
self.date.map(chrono::DateTime::naive_utc),
|
||||
self.date.map(|x| time::PrimitiveDateTime::new(x.date(), x.time())),
|
||||
)
|
||||
.fetch_one(exec)
|
||||
.await?;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::ids::*;
|
||||
use crate::database::models::DatabaseError;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub struct NotificationBuilder {
|
||||
pub notification_type: Option<String>,
|
||||
@@ -22,7 +23,7 @@ pub struct Notification {
|
||||
pub text: String,
|
||||
pub link: String,
|
||||
pub read: bool,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
pub created: OffsetDateTime,
|
||||
pub actions: Vec<NotificationAction>,
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ impl NotificationBuilder {
|
||||
text: self.text.clone(),
|
||||
link: self.link.clone(),
|
||||
read: false,
|
||||
created: chrono::Utc::now(),
|
||||
created: OffsetDateTime::now_utc(),
|
||||
actions,
|
||||
}
|
||||
.insert(&mut *transaction)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::ids::*;
|
||||
use chrono::{DateTime, Utc};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DonationUrl {
|
||||
@@ -42,7 +42,7 @@ pub struct GalleryItem {
|
||||
pub featured: bool,
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub created: DateTime<Utc>,
|
||||
pub created: OffsetDateTime,
|
||||
}
|
||||
|
||||
impl GalleryItem {
|
||||
@@ -109,8 +109,8 @@ impl ProjectBuilder {
|
||||
description: self.description,
|
||||
body: self.body,
|
||||
body_url: None,
|
||||
published: chrono::Utc::now(),
|
||||
updated: chrono::Utc::now(),
|
||||
published: time::OffsetDateTime::now_utc(),
|
||||
updated: time::OffsetDateTime::now_utc(),
|
||||
status: self.status,
|
||||
downloads: 0,
|
||||
follows: 0,
|
||||
@@ -169,8 +169,8 @@ pub struct Project {
|
||||
pub description: String,
|
||||
pub body: String,
|
||||
pub body_url: Option<String>,
|
||||
pub published: chrono::DateTime<chrono::Utc>,
|
||||
pub updated: chrono::DateTime<chrono::Utc>,
|
||||
pub published: time::OffsetDateTime,
|
||||
pub updated: time::OffsetDateTime,
|
||||
pub status: StatusId,
|
||||
pub downloads: i32,
|
||||
pub follows: i32,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::ids::*;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub struct Report {
|
||||
pub id: ReportId,
|
||||
@@ -8,7 +9,7 @@ pub struct Report {
|
||||
pub user_id: Option<UserId>,
|
||||
pub body: String,
|
||||
pub reporter: UserId,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
pub created: OffsetDateTime,
|
||||
}
|
||||
|
||||
pub struct QueryReport {
|
||||
@@ -19,7 +20,7 @@ pub struct QueryReport {
|
||||
pub user_id: Option<UserId>,
|
||||
pub body: String,
|
||||
pub reporter: UserId,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
pub created: OffsetDateTime,
|
||||
}
|
||||
|
||||
impl Report {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::ids::{ProjectId, UserId};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub struct User {
|
||||
pub id: UserId,
|
||||
@@ -8,7 +9,7 @@ pub struct User {
|
||||
pub email: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
pub bio: Option<String>,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
pub created: OffsetDateTime,
|
||||
pub role: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::ids::*;
|
||||
use super::DatabaseError;
|
||||
use std::collections::HashMap;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub struct VersionBuilder {
|
||||
pub version_id: VersionId,
|
||||
@@ -78,6 +79,7 @@ pub struct VersionFileBuilder {
|
||||
pub filename: String,
|
||||
pub hashes: Vec<HashBuilder>,
|
||||
pub primary: bool,
|
||||
pub size: u32,
|
||||
}
|
||||
|
||||
impl VersionFileBuilder {
|
||||
@@ -90,14 +92,15 @@ impl VersionFileBuilder {
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO files (id, version_id, url, filename, is_primary)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
INSERT INTO files (id, version_id, url, filename, is_primary, size)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
",
|
||||
file_id as FileId,
|
||||
version_id as VersionId,
|
||||
self.url,
|
||||
self.filename,
|
||||
self.primary
|
||||
self.primary,
|
||||
self.size as i32
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
@@ -138,7 +141,7 @@ impl VersionBuilder {
|
||||
version_number: self.version_number,
|
||||
changelog: self.changelog,
|
||||
changelog_url: None,
|
||||
date_published: chrono::Utc::now(),
|
||||
date_published: OffsetDateTime::now_utc(),
|
||||
downloads: 0,
|
||||
featured: self.featured,
|
||||
version_type: self.version_type,
|
||||
@@ -238,7 +241,7 @@ pub struct Version {
|
||||
pub version_number: String,
|
||||
pub changelog: String,
|
||||
pub changelog_url: Option<String>,
|
||||
pub date_published: chrono::DateTime<chrono::Utc>,
|
||||
pub date_published: OffsetDateTime,
|
||||
pub downloads: i32,
|
||||
pub version_type: String,
|
||||
pub featured: bool,
|
||||
@@ -639,7 +642,7 @@ impl Version {
|
||||
).fetch_all(executor),
|
||||
sqlx::query!(
|
||||
"
|
||||
SELECT id, filename, is_primary, url
|
||||
SELECT id, filename, is_primary, url, size
|
||||
FROM files
|
||||
WHERE version_id = $1
|
||||
",
|
||||
@@ -699,6 +702,7 @@ impl Version {
|
||||
.or_default()
|
||||
.clone(),
|
||||
primary: x.is_primary,
|
||||
size: x.size as u32,
|
||||
})
|
||||
.collect(),
|
||||
game_versions: game_versions?
|
||||
@@ -760,7 +764,7 @@ pub struct QueryVersion {
|
||||
pub version_number: String,
|
||||
pub changelog: String,
|
||||
pub changelog_url: Option<String>,
|
||||
pub date_published: chrono::DateTime<chrono::Utc>,
|
||||
pub date_published: OffsetDateTime,
|
||||
pub downloads: i32,
|
||||
|
||||
pub version_type: String,
|
||||
@@ -785,4 +789,5 @@ pub struct QueryFile {
|
||||
pub filename: String,
|
||||
pub hashes: HashMap<String, Vec<u8>>,
|
||||
pub primary: bool,
|
||||
pub size: u32,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user