Skip to content
55 changes: 55 additions & 0 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ members = [
"apps/labrinth",
"packages/app-lib",
"packages/ariadne",
"packages/cached-projection",
"packages/cached-projection-derive",
"packages/daedalus",
"packages/labrinth-derive",
"packages/modrinth-content-management",
Expand Down Expand Up @@ -54,6 +56,7 @@ bitflags = "2.9.4"
bon = "3.9.3"
bytemuck = "1.24.0"
bytes = "1.10.1"
cached-projection = { path = "packages/cached-projection" }
censor = "0.3.0"
chardetng = "0.1.17"
chrono = "0.4.42"
Expand Down Expand Up @@ -118,6 +121,12 @@ lettre = { version = "0.11.19", default-features = false, features = [
"tokio1",
"tokio1-rustls",
] }
lz4_flex = { version = "0.11.5", default-features = false, features = [
"checked-decode",
"safe-decode",
"safe-encode",
"std",
] }
maxminddb = "0.26.0"
meilisearch-sdk = { version = "0.30.0", default-features = false }
modrinth-content-management = { path = "packages/modrinth-content-management" }
Expand All @@ -135,6 +144,7 @@ paste = "1.0.15"
path-util = { path = "packages/path-util" }
phf = { version = "0.13.1", features = ["macros"] }
png = "0.18.0"
postcard = { version = "1.1.3", default-features = false, features = ["alloc"] }
proc-macro2 = { version = "1.0" }
prometheus = "0.14.0"
quartz_nbt = "0.2.9"
Expand Down
3 changes: 3 additions & 0 deletions apps/labrinth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ aws-sdk-s3 = { workspace = true }
base64 = { workspace = true }
bitflags = { workspace = true }
bytes = { workspace = true }
cached-projection = { workspace = true }
censor = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
clap = { workspace = true, features = ["derive"] }
Expand Down Expand Up @@ -73,13 +74,15 @@ image = { workspace = true, features = [
itertools = { workspace = true }
json-patch = { workspace = true }
lettre = { workspace = true }
lz4_flex = { workspace = true }
meilisearch-sdk = { workspace = true, features = ["reqwest"] }
modrinth-content-management = { workspace = true }
modrinth-util = { workspace = true, features = ["decimal", "sentry", "utoipa"] }
muralpay = { workspace = true, features = ["client", "mock", "utoipa"] }
murmur2 = { workspace = true }
paste = { workspace = true }
path-util = { workspace = true }
postcard = { workspace = true }
prometheus = { workspace = true }
quick-xml = { workspace = true }
rand = { workspace = true }
Expand Down
9 changes: 5 additions & 4 deletions apps/labrinth/src/database/models/analytics_event_item.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cached_projection::CachedProjection;
use chrono::{DateTime, Utc};
use futures::{StreamExt, TryStreamExt};
use sqlx::types::Json;
Expand All @@ -11,10 +12,10 @@ use crate::{
};
use serde::{Deserialize, Serialize};

const ANALYTICS_EVENTS_NAMESPACE: &str = "analytics_events";
const ANALYTICS_EVENTS_NAMESPACE: &str = "analytics_events:v1";
const ANALYTICS_EVENTS_ALL_KEY: &str = "all";

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, CachedProjection)]
pub struct DBAnalyticsEvent {
pub id: DBAnalyticsEventId,
pub meta: AnalyticsEventMeta,
Expand Down Expand Up @@ -88,7 +89,7 @@ impl DBAnalyticsEvent {
let mut redis = redis.connect().await?;

if let Some(events) = redis
.get_deserialized_from_json(
.get_deserialized(
ANALYTICS_EVENTS_NAMESPACE,
ANALYTICS_EVENTS_ALL_KEY,
)
Expand Down Expand Up @@ -119,7 +120,7 @@ impl DBAnalyticsEvent {
.await?;

redis
.set_serialized_to_json(
.set_serialized(
ANALYTICS_EVENTS_NAMESPACE,
ANALYTICS_EVENTS_ALL_KEY,
&events,
Expand Down
41 changes: 13 additions & 28 deletions apps/labrinth/src/database/models/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ use crate::database::redis::RedisPool;

use super::DatabaseError;
use super::ids::*;
use cached_projection::CachedProjection;
use futures::TryStreamExt;
use serde::{Deserialize, Serialize};

const TAGS_NAMESPACE: &str = "tags";
const TAGS_NAMESPACE: &str = "tags:v1";

pub struct ProjectType {
pub id: ProjectTypeId,
pub name: String,
}

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, CachedProjection)]
pub struct Category {
pub id: CategoryId,
pub category: String,
Expand All @@ -28,7 +29,7 @@ pub struct ReportType {
pub report_type: String,
}

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, CachedProjection)]
pub struct LinkPlatform {
pub id: LinkPlatformId,
pub name: String,
Expand Down Expand Up @@ -96,9 +97,8 @@ impl Category {
{
let mut redis = redis.connect().await?;

let res: Option<Vec<Category>> = redis
.get_deserialized_from_json(TAGS_NAMESPACE, "category")
.await?;
let res: Option<Vec<Category>> =
redis.get_deserialized(TAGS_NAMESPACE, "category").await?;

if let Some(res) = res {
return Ok(res);
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Category {
let mut redis = redis.connect().await?;

redis
.set_serialized_to_json(TAGS_NAMESPACE, "category", &result, None)
.set_serialized(TAGS_NAMESPACE, "category", &result, None)
.await?;

Ok(result)
Expand Down Expand Up @@ -166,7 +166,7 @@ impl LinkPlatform {
let mut redis = redis.connect().await?;

let res: Option<Vec<LinkPlatform>> = redis
.get_deserialized_from_json(TAGS_NAMESPACE, "link_platform")
.get_deserialized(TAGS_NAMESPACE, "link_platform")
.await?;

if let Some(res) = res {
Expand All @@ -191,12 +191,7 @@ impl LinkPlatform {
let mut redis = redis.connect().await?;

redis
.set_serialized_to_json(
TAGS_NAMESPACE,
"link_platform",
&result,
None,
)
.set_serialized(TAGS_NAMESPACE, "link_platform", &result, None)
.await?;

Ok(result)
Expand Down Expand Up @@ -235,7 +230,7 @@ impl ReportType {
let mut redis = redis.connect().await?;

let res: Option<Vec<String>> = redis
.get_deserialized_from_json(TAGS_NAMESPACE, "report_type")
.get_deserialized(TAGS_NAMESPACE, "report_type")
.await?;

if let Some(res) = res {
Expand All @@ -256,12 +251,7 @@ impl ReportType {
let mut redis = redis.connect().await?;

redis
.set_serialized_to_json(
TAGS_NAMESPACE,
"report_type",
&result,
None,
)
.set_serialized(TAGS_NAMESPACE, "report_type", &result, None)
.await?;

Ok(result)
Expand Down Expand Up @@ -300,7 +290,7 @@ impl ProjectType {
let mut redis = redis.connect().await?;

let res: Option<Vec<String>> = redis
.get_deserialized_from_json(TAGS_NAMESPACE, "project_type")
.get_deserialized(TAGS_NAMESPACE, "project_type")
.await?;

if let Some(res) = res {
Expand All @@ -321,12 +311,7 @@ impl ProjectType {
let mut redis = redis.connect().await?;

redis
.set_serialized_to_json(
TAGS_NAMESPACE,
"project_type",
&result,
None,
)
.set_serialized(TAGS_NAMESPACE, "project_type", &result, None)
.await?;

Ok(result)
Expand Down
5 changes: 3 additions & 2 deletions apps/labrinth/src/database/models/collection_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use crate::database::models::DatabaseError;
use crate::database::redis::RedisPool;
use crate::database::{PgTransaction, models};
use crate::models::collections::CollectionStatus;
use cached_projection::CachedProjection;
use chrono::{DateTime, Utc};
use dashmap::DashMap;
use futures::TryStreamExt;
use serde::{Deserialize, Serialize};

const COLLECTIONS_NAMESPACE: &str = "collections";
const COLLECTIONS_NAMESPACE: &str = "collections:v1";

#[derive(Clone)]
pub struct CollectionBuilder {
Expand Down Expand Up @@ -43,7 +44,7 @@ impl CollectionBuilder {
Ok(self.collection_id)
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, CachedProjection)]
pub struct DBCollection {
pub id: DBCollectionId,
pub user_id: DBUserId,
Expand Down
Loading
Loading