More project data (#406)

* More project data

* Array_agg fixes + cleanup

* fix prepare

* Add approval dates to search

* Update migrations/20220725204351_more-project-data.sql

Co-authored-by: wafflecoffee <emmaffle@modrinth.com>

* Add category labels + display categories

Co-authored-by: wafflecoffee <emmaffle@modrinth.com>
This commit is contained in:
Geometrically
2022-07-31 13:29:20 -07:00
committed by GitHub
parent 13335cadc6
commit b04bced37f
38 changed files with 3673 additions and 3517 deletions

View File

@@ -3,6 +3,5 @@ pub mod env;
pub mod ext;
pub mod guards;
pub mod routes;
pub mod time_ser;
pub mod validate;
pub mod webhook;

View File

@@ -1,42 +0,0 @@
//! Use the well-known [RFC3339 format] when serializing and deserializing an [`OffsetDateTime`].
//!
//! Use this module in combination with serde's [`#[with]`][with] attribute.
//!
//! [RFC3339 format]: https://tools.ietf.org/html/rfc3339#section-5.6
//! [with]: https://serde.rs/field-attrs.html#with
use core::fmt;
use core::marker::PhantomData;
use serde::{de, Deserializer, Serialize, Serializer};
use time::Format::Rfc3339;
use time::OffsetDateTime;
/// Serialize an [`OffsetDateTime`] using the well-known RFC3339 format.
pub fn serialize<S: Serializer>(
datetime: &OffsetDateTime,
serializer: S,
) -> Result<S::Ok, S::Error> {
datetime.format(Rfc3339).serialize(serializer)
}
/// Deserialize an [`OffsetDateTime`] from its RFC3339 representation.
pub fn deserialize<'a, D: Deserializer<'a>>(
deserializer: D,
) -> Result<OffsetDateTime, D::Error> {
deserializer.deserialize_any(Visitor(PhantomData))
}
pub(super) struct Visitor<T: ?Sized>(pub(super) PhantomData<T>);
impl<'a> de::Visitor<'a> for Visitor<OffsetDateTime> {
type Value = OffsetDateTime;
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("an `OffsetDateTime`")
}
fn visit_str<E: de::Error>(self, value: &str) -> Result<OffsetDateTime, E> {
OffsetDateTime::parse(value, Rfc3339).map_err(E::custom)
}
}

View File

@@ -1,14 +1,13 @@
use crate::models::projects::Project;
use chrono::{DateTime, Utc};
use serde::Serialize;
use time::OffsetDateTime;
#[derive(Serialize)]
struct DiscordEmbed {
pub title: String,
pub description: String,
pub url: String,
#[serde(with = "crate::util::time_ser")]
pub timestamp: OffsetDateTime,
pub timestamp: DateTime<Utc>,
pub color: u32,
pub fields: Vec<DiscordEmbedField>,
pub image: DiscordEmbedImage,