You've already forked AstralRinth
forked from didirus/AstralRinth
Commonize and distinguish a lot of struct names in labrinth::database::models (#3691)
This commit is contained in:
@@ -103,7 +103,7 @@ impl LegacyProject {
|
||||
// It's safe to use a db version_item for this as the only info is side types, game versions, and loader fields (for loaders), which used to be public on project anyway.
|
||||
pub fn from(
|
||||
data: Project,
|
||||
versions_item: Option<version_item::QueryVersion>,
|
||||
versions_item: Option<version_item::VersionQueryResult>,
|
||||
) -> Self {
|
||||
let mut client_side = LegacySideType::Unknown;
|
||||
let mut server_side = LegacySideType::Unknown;
|
||||
@@ -237,7 +237,8 @@ impl LegacyProject {
|
||||
.filter_map(|p| p.versions.first().map(|i| (*i).into()))
|
||||
.collect();
|
||||
let example_versions =
|
||||
version_item::Version::get_many(&version_ids, exec, redis).await?;
|
||||
version_item::DBVersion::get_many(&version_ids, exec, redis)
|
||||
.await?;
|
||||
let mut legacy_projects = Vec::new();
|
||||
for project in data {
|
||||
let version_item = example_versions
|
||||
|
||||
@@ -90,11 +90,11 @@ pub struct UserSubscription {
|
||||
pub metadata: Option<SubscriptionMetadata>,
|
||||
}
|
||||
|
||||
impl From<crate::database::models::user_subscription_item::UserSubscriptionItem>
|
||||
impl From<crate::database::models::user_subscription_item::DBUserSubscription>
|
||||
for UserSubscription
|
||||
{
|
||||
fn from(
|
||||
x: crate::database::models::user_subscription_item::UserSubscriptionItem,
|
||||
x: crate::database::models::user_subscription_item::DBUserSubscription,
|
||||
) -> Self {
|
||||
Self {
|
||||
id: x.id.into(),
|
||||
|
||||
@@ -35,8 +35,8 @@ pub struct Collection {
|
||||
pub projects: Vec<ProjectId>,
|
||||
}
|
||||
|
||||
impl From<database::models::Collection> for Collection {
|
||||
fn from(c: database::models::Collection) -> Self {
|
||||
impl From<database::models::DBCollection> for Collection {
|
||||
fn from(c: database::models::DBCollection) -> Self {
|
||||
Self {
|
||||
id: c.id.into(),
|
||||
user: c.user_id.into(),
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::{
|
||||
ids::{ProjectId, ThreadMessageId, VersionId},
|
||||
pats::Scopes,
|
||||
};
|
||||
use crate::database::models::image_item::Image as DBImage;
|
||||
use crate::database::models::image_item::DBImage;
|
||||
use crate::models::ids::{ImageId, ReportId};
|
||||
use ariadne::ids::UserId;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::ids::OrganizationId;
|
||||
use crate::database::models::notification_item::Notification as DBNotification;
|
||||
use crate::database::models::notification_item::NotificationAction as DBNotificationAction;
|
||||
use crate::database::models::notification_item::DBNotification;
|
||||
use crate::database::models::notification_item::DBNotificationAction;
|
||||
use crate::models::ids::{
|
||||
NotificationId, ProjectId, ReportId, TeamId, ThreadId, ThreadMessageId,
|
||||
VersionId,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::pats::Scopes;
|
||||
use crate::database::models::oauth_client_authorization_item::OAuthClientAuthorization as DBOAuthClientAuthorization;
|
||||
use crate::database::models::oauth_client_item::OAuthClient as DBOAuthClient;
|
||||
use crate::database::models::oauth_client_item::OAuthRedirectUri as DBOAuthRedirectUri;
|
||||
use crate::database::models::oauth_client_authorization_item::DBOAuthClientAuthorization;
|
||||
use crate::database::models::oauth_client_item::DBOAuthClient;
|
||||
use crate::database::models::oauth_client_item::DBOAuthRedirectUri;
|
||||
use crate::models::ids::{
|
||||
OAuthClientAuthorizationId, OAuthClientId, OAuthRedirectUriId,
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ pub struct Organization {
|
||||
|
||||
impl Organization {
|
||||
pub fn from(
|
||||
data: crate::database::models::organization_item::Organization,
|
||||
data: crate::database::models::organization_item::DBOrganization,
|
||||
team_members: Vec<TeamMember>,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -155,7 +155,7 @@ pub struct PersonalAccessToken {
|
||||
|
||||
impl PersonalAccessToken {
|
||||
pub fn from(
|
||||
data: crate::database::models::pat_item::PersonalAccessToken,
|
||||
data: crate::database::models::pat_item::DBPersonalAccessToken,
|
||||
include_token: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -22,7 +22,7 @@ pub struct Payout {
|
||||
}
|
||||
|
||||
impl Payout {
|
||||
pub fn from(data: crate::database::models::payout_item::Payout) -> Self {
|
||||
pub fn from(data: crate::database::models::payout_item::DBPayout) -> Self {
|
||||
Self {
|
||||
id: data.id.into(),
|
||||
user_id: data.user_id.into(),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use crate::database::models::loader_fields::VersionField;
|
||||
use crate::database::models::project_item::{LinkUrl, QueryProject};
|
||||
use crate::database::models::version_item::QueryVersion;
|
||||
use crate::database::models::project_item::{LinkUrl, ProjectQueryResult};
|
||||
use crate::database::models::version_item::VersionQueryResult;
|
||||
use crate::models::ids::{
|
||||
OrganizationId, ProjectId, TeamId, ThreadId, VersionId,
|
||||
};
|
||||
@@ -139,8 +139,8 @@ pub fn from_duplicate_version_fields(
|
||||
fields
|
||||
}
|
||||
|
||||
impl From<QueryProject> for Project {
|
||||
fn from(data: QueryProject) -> Self {
|
||||
impl From<ProjectQueryResult> for Project {
|
||||
fn from(data: ProjectQueryResult) -> Self {
|
||||
let fields =
|
||||
from_duplicate_version_fields(data.aggregate_version_fields);
|
||||
let m = data.inner;
|
||||
@@ -657,8 +657,8 @@ where
|
||||
Ok(map)
|
||||
}
|
||||
|
||||
impl From<QueryVersion> for Version {
|
||||
fn from(data: QueryVersion) -> Version {
|
||||
impl From<VersionQueryResult> for Version {
|
||||
fn from(data: VersionQueryResult) -> Version {
|
||||
let v = data.inner;
|
||||
Version {
|
||||
id: v.id.into(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::database::models::report_item::QueryReport as DBReport;
|
||||
use crate::database::models::report_item::ReportQueryResult as DBReport;
|
||||
use crate::models::ids::{ProjectId, ReportId, ThreadId, VersionId};
|
||||
use ariadne::ids::UserId;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
@@ -27,7 +27,7 @@ pub struct Session {
|
||||
|
||||
impl Session {
|
||||
pub fn from(
|
||||
data: crate::database::models::session_item::Session,
|
||||
data: crate::database::models::session_item::DBSession,
|
||||
include_session: bool,
|
||||
current_session: Option<&str>,
|
||||
) -> Self {
|
||||
|
||||
@@ -42,8 +42,10 @@ impl Default for ProjectPermissions {
|
||||
impl ProjectPermissions {
|
||||
pub fn get_permissions_by_role(
|
||||
role: &crate::models::users::Role,
|
||||
project_team_member: &Option<crate::database::models::TeamMember>, // team member of the user in the project
|
||||
organization_team_member: &Option<crate::database::models::TeamMember>, // team member of the user in the organization
|
||||
project_team_member: &Option<crate::database::models::DBTeamMember>, // team member of the user in the project
|
||||
organization_team_member: &Option<
|
||||
crate::database::models::DBTeamMember,
|
||||
>, // team member of the user in the organization
|
||||
) -> Option<Self> {
|
||||
if role.is_admin() {
|
||||
return Some(ProjectPermissions::all());
|
||||
@@ -99,7 +101,7 @@ impl Default for OrganizationPermissions {
|
||||
impl OrganizationPermissions {
|
||||
pub fn get_permissions_by_role(
|
||||
role: &crate::models::users::Role,
|
||||
team_member: &Option<crate::database::models::TeamMember>,
|
||||
team_member: &Option<crate::database::models::DBTeamMember>,
|
||||
) -> Option<Self> {
|
||||
if role.is_admin() {
|
||||
return Some(OrganizationPermissions::all());
|
||||
@@ -154,8 +156,8 @@ pub struct TeamMember {
|
||||
|
||||
impl TeamMember {
|
||||
pub fn from(
|
||||
data: crate::database::models::team_item::TeamMember,
|
||||
user: crate::database::models::User,
|
||||
data: crate::database::models::team_item::DBTeamMember,
|
||||
user: crate::database::models::DBUser,
|
||||
override_permissions: bool,
|
||||
) -> Self {
|
||||
let user: User = user.into();
|
||||
@@ -166,7 +168,7 @@ impl TeamMember {
|
||||
// if already available.
|
||||
// (Avoids a db query in some cases)
|
||||
pub fn from_model(
|
||||
data: crate::database::models::team_item::TeamMember,
|
||||
data: crate::database::models::team_item::DBTeamMember,
|
||||
user: crate::models::users::User,
|
||||
override_permissions: bool,
|
||||
) -> Self {
|
||||
|
||||
@@ -86,7 +86,7 @@ impl ThreadType {
|
||||
|
||||
impl Thread {
|
||||
pub fn from(
|
||||
data: crate::database::models::Thread,
|
||||
data: crate::database::models::DBThread,
|
||||
users: Vec<User>,
|
||||
user: &User,
|
||||
) -> Self {
|
||||
@@ -119,7 +119,7 @@ impl Thread {
|
||||
|
||||
impl ThreadMessage {
|
||||
pub fn from(
|
||||
data: crate::database::models::ThreadMessage,
|
||||
data: crate::database::models::DBThreadMessage,
|
||||
user: &User,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -63,7 +63,7 @@ pub struct UserPayoutData {
|
||||
pub balance: Decimal,
|
||||
}
|
||||
|
||||
use crate::database::models::user_item::User as DBUser;
|
||||
use crate::database::models::user_item::DBUser;
|
||||
impl From<DBUser> for User {
|
||||
fn from(data: DBUser) -> Self {
|
||||
Self {
|
||||
@@ -196,9 +196,7 @@ pub struct UserFriend {
|
||||
}
|
||||
|
||||
impl UserFriend {
|
||||
pub fn from(
|
||||
data: crate::database::models::friend_item::FriendItem,
|
||||
) -> Self {
|
||||
pub fn from(data: crate::database::models::friend_item::DBFriend) -> Self {
|
||||
Self {
|
||||
id: data.friend_id.into(),
|
||||
friend_id: data.user_id.into(),
|
||||
|
||||
Reference in New Issue
Block a user