feat: simplify database scheme
ci/woodpecker/push/clippy Pipeline is pending Details
ci/woodpecker/push/lint Pipeline is pending Details
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/docker unknown status Details

db-centric-repos
Jef Roosens 2024-05-18 14:20:05 +02:00
parent fcb3a18416
commit 9963cff724
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
15 changed files with 96 additions and 370 deletions

View File

@ -3,11 +3,8 @@
pub mod prelude; pub mod prelude;
pub mod package; pub mod package;
pub mod package_conflicts;
pub mod package_depends;
pub mod package_file; pub mod package_file;
pub mod package_group; pub mod package_group;
pub mod package_license; pub mod package_license;
pub mod package_provides; pub mod package_related;
pub mod package_replaces;
pub mod repo; pub mod repo;

View File

@ -17,7 +17,7 @@ pub struct Model {
pub c_size: i64, pub c_size: i64,
pub description: Option<String>, pub description: Option<String>,
pub url: Option<String>, pub url: Option<String>,
pub build_date: DateTime, pub build_date: String,
pub packager: Option<String>, pub packager: Option<String>,
pub pgp_sig: Option<String>, pub pgp_sig: Option<String>,
pub pgp_sig_size: Option<i64>, pub pgp_sig_size: Option<i64>,
@ -26,20 +26,14 @@ pub struct Model {
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation { pub enum Relation {
#[sea_orm(has_many = "super::package_conflicts::Entity")]
PackageConflicts,
#[sea_orm(has_many = "super::package_depends::Entity")]
PackageDepends,
#[sea_orm(has_many = "super::package_file::Entity")] #[sea_orm(has_many = "super::package_file::Entity")]
PackageFile, PackageFile,
#[sea_orm(has_many = "super::package_group::Entity")] #[sea_orm(has_many = "super::package_group::Entity")]
PackageGroup, PackageGroup,
#[sea_orm(has_many = "super::package_license::Entity")] #[sea_orm(has_many = "super::package_license::Entity")]
PackageLicense, PackageLicense,
#[sea_orm(has_many = "super::package_provides::Entity")] #[sea_orm(has_many = "super::package_related::Entity")]
PackageProvides, PackageRelated,
#[sea_orm(has_many = "super::package_replaces::Entity")]
PackageReplaces,
#[sea_orm( #[sea_orm(
belongs_to = "super::repo::Entity", belongs_to = "super::repo::Entity",
from = "Column::RepoId", from = "Column::RepoId",
@ -50,18 +44,6 @@ pub enum Relation {
Repo, Repo,
} }
impl Related<super::package_conflicts::Entity> for Entity {
fn to() -> RelationDef {
Relation::PackageConflicts.def()
}
}
impl Related<super::package_depends::Entity> for Entity {
fn to() -> RelationDef {
Relation::PackageDepends.def()
}
}
impl Related<super::package_file::Entity> for Entity { impl Related<super::package_file::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::PackageFile.def() Relation::PackageFile.def()
@ -80,15 +62,9 @@ impl Related<super::package_license::Entity> for Entity {
} }
} }
impl Related<super::package_provides::Entity> for Entity { impl Related<super::package_related::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::PackageProvides.def() Relation::PackageRelated.def()
}
}
impl Related<super::package_replaces::Entity> for Entity {
fn to() -> RelationDef {
Relation::PackageReplaces.def()
} }
} }

View File

@ -1,33 +0,0 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "package_conflicts")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)]
pub value: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::package::Entity",
from = "Column::PackageId",
to = "super::package::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Package,
}
impl Related<super::package::Entity> for Entity {
fn to() -> RelationDef {
Relation::Package.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -9,7 +9,7 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32, pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub value: String, pub path: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -9,7 +9,7 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32, pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub value: String, pub name: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -9,7 +9,7 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32, pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub value: String, pub name: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -1,33 +0,0 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "package_provides")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)]
pub value: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::package::Entity",
from = "Column::PackageId",
to = "super::package::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Package,
}
impl Related<super::package::Entity> for Entity {
fn to() -> RelationDef {
Relation::Package.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -4,14 +4,14 @@ use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "package_depends")] #[sea_orm(table_name = "package_related")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32, pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub r#type: crate::db::PackageDepend, pub r#type: crate::db::PackageRelatedEnum,
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub value: String, pub name: String,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -1,33 +0,0 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "package_replaces")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub package_id: i32,
#[sea_orm(primary_key, auto_increment = false)]
pub value: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::package::Entity",
from = "Column::PackageId",
to = "super::package::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Package,
}
impl Related<super::package::Entity> for Entity {
fn to() -> RelationDef {
Relation::Package.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -1,11 +1,8 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1 //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
pub use super::package::Entity as Package; pub use super::package::Entity as Package;
pub use super::package_conflicts::Entity as PackageConflicts;
pub use super::package_depends::Entity as PackageDepends;
pub use super::package_file::Entity as PackageFile; pub use super::package_file::Entity as PackageFile;
pub use super::package_group::Entity as PackageGroup; pub use super::package_group::Entity as PackageGroup;
pub use super::package_license::Entity as PackageLicense; pub use super::package_license::Entity as PackageLicense;
pub use super::package_provides::Entity as PackageProvides; pub use super::package_related::Entity as PackageRelated;
pub use super::package_replaces::Entity as PackageReplaces;
pub use super::repo::Entity as Repo; pub use super::repo::Entity as Repo;

View File

@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize};
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
pub id: i32, pub id: i32,
#[sea_orm(unique)]
pub name: String, pub name: String,
pub description: Option<String>, pub description: Option<String>,
} }

View File

@ -72,14 +72,14 @@ impl MigrationTrait for Migration {
.not_null(), .not_null(),
) )
.col( .col(
ColumnDef::new(PackageLicense::Value) ColumnDef::new(PackageLicense::Name)
.string_len(255) .string_len(255)
.not_null(), .not_null(),
) )
.primary_key( .primary_key(
Index::create() Index::create()
.col(PackageLicense::PackageId) .col(PackageLicense::PackageId)
.col(PackageLicense::Value), .col(PackageLicense::Name),
) )
.foreign_key( .foreign_key(
ForeignKey::create() ForeignKey::create()
@ -97,14 +97,14 @@ impl MigrationTrait for Migration {
.table(PackageGroup::Table) .table(PackageGroup::Table)
.col(ColumnDef::new(PackageGroup::PackageId).integer().not_null()) .col(ColumnDef::new(PackageGroup::PackageId).integer().not_null())
.col( .col(
ColumnDef::new(PackageGroup::Value) ColumnDef::new(PackageGroup::Name)
.string_len(255) .string_len(255)
.not_null(), .not_null(),
) )
.primary_key( .primary_key(
Index::create() Index::create()
.col(PackageGroup::PackageId) .col(PackageGroup::PackageId)
.col(PackageGroup::Value), .col(PackageGroup::Name),
) )
.foreign_key( .foreign_key(
ForeignKey::create() ForeignKey::create()
@ -119,119 +119,28 @@ impl MigrationTrait for Migration {
manager manager
.create_table( .create_table(
Table::create() Table::create()
.table(PackageReplaces::Table) .table(PackageRelated::Table)
.col( .col(
ColumnDef::new(PackageReplaces::PackageId) ColumnDef::new(PackageRelated::PackageId)
.integer() .integer()
.not_null(), .not_null(),
) )
.col(ColumnDef::new(PackageRelated::Type).integer().not_null())
.col( .col(
ColumnDef::new(PackageReplaces::Value) ColumnDef::new(PackageRelated::Name)
.string_len(255) .string_len(255)
.not_null(), .not_null(),
) )
.primary_key( .primary_key(
Index::create() Index::create()
.col(PackageReplaces::PackageId) .col(PackageRelated::PackageId)
.col(PackageReplaces::Value), .col(PackageRelated::Type)
) .col(PackageRelated::Name),
.foreign_key(
ForeignKey::create()
.name("fk-package_replaces-package_id")
.from(PackageReplaces::Table, PackageReplaces::PackageId)
.to(Package::Table, Package::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()
.table(PackageConflicts::Table)
.col(
ColumnDef::new(PackageConflicts::PackageId)
.integer()
.not_null(),
)
.col(
ColumnDef::new(PackageConflicts::Value)
.string_len(255)
.not_null(),
)
.primary_key(
Index::create()
.col(PackageConflicts::PackageId)
.col(PackageConflicts::Value),
)
.foreign_key(
ForeignKey::create()
.name("fk-package_conflicts-package_id")
.from(PackageConflicts::Table, PackageConflicts::PackageId)
.to(Package::Table, Package::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()
.table(PackageProvides::Table)
.col(
ColumnDef::new(PackageProvides::PackageId)
.integer()
.not_null(),
)
.col(
ColumnDef::new(PackageProvides::Value)
.string_len(255)
.not_null(),
)
.primary_key(
Index::create()
.col(PackageProvides::PackageId)
.col(PackageProvides::Value),
)
.foreign_key(
ForeignKey::create()
.name("fk-package_provides-package_id")
.from(PackageProvides::Table, PackageProvides::PackageId)
.to(Package::Table, Package::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()
.table(PackageDepends::Table)
.col(
ColumnDef::new(PackageDepends::PackageId)
.integer()
.not_null(),
)
.col(
ColumnDef::new(PackageDepends::Type)
.string_len(6)
.not_null(),
)
.col(
ColumnDef::new(PackageDepends::Value)
.string_len(255)
.not_null(),
)
.primary_key(
Index::create()
.col(PackageDepends::PackageId)
.col(PackageDepends::Type)
.col(PackageDepends::Value),
) )
.foreign_key( .foreign_key(
ForeignKey::create() ForeignKey::create()
.name("fk-package_depends-package_id") .name("fk-package_depends-package_id")
.from(PackageDepends::Table, PackageDepends::PackageId) .from(PackageRelated::Table, PackageRelated::PackageId)
.to(Package::Table, Package::Id) .to(Package::Table, Package::Id)
.on_delete(ForeignKeyAction::Cascade), .on_delete(ForeignKeyAction::Cascade),
) )
@ -243,15 +152,11 @@ impl MigrationTrait for Migration {
Table::create() Table::create()
.table(PackageFile::Table) .table(PackageFile::Table)
.col(ColumnDef::new(PackageFile::PackageId).integer().not_null()) .col(ColumnDef::new(PackageFile::PackageId).integer().not_null())
.col( .col(ColumnDef::new(PackageFile::Path).string_len(255).not_null())
ColumnDef::new(PackageFile::Value)
.string_len(255)
.not_null(),
)
.primary_key( .primary_key(
Index::create() Index::create()
.col(PackageFile::PackageId) .col(PackageFile::PackageId)
.col(PackageFile::Value), .col(PackageFile::Path),
) )
.foreign_key( .foreign_key(
ForeignKey::create() ForeignKey::create()
@ -276,16 +181,7 @@ impl MigrationTrait for Migration {
.drop_table(Table::drop().table(PackageGroup::Table).to_owned()) .drop_table(Table::drop().table(PackageGroup::Table).to_owned())
.await?; .await?;
manager manager
.drop_table(Table::drop().table(PackageReplaces::Table).to_owned()) .drop_table(Table::drop().table(PackageRelated::Table).to_owned())
.await?;
manager
.drop_table(Table::drop().table(PackageConflicts::Table).to_owned())
.await?;
manager
.drop_table(Table::drop().table(PackageProvides::Table).to_owned())
.await?;
manager
.drop_table(Table::drop().table(PackageDepends::Table).to_owned())
.await?; .await?;
manager manager
.drop_table(Table::drop().table(PackageFile::Table).to_owned()) .drop_table(Table::drop().table(PackageFile::Table).to_owned())
@ -331,48 +227,27 @@ pub enum Package {
pub enum PackageLicense { pub enum PackageLicense {
Table, Table,
PackageId, PackageId,
Value, Name,
} }
#[derive(Iden)] #[derive(Iden)]
pub enum PackageGroup { pub enum PackageGroup {
Table, Table,
PackageId, PackageId,
Value, Name,
} }
#[derive(Iden)] #[derive(Iden)]
pub enum PackageReplaces { pub enum PackageRelated {
Table,
PackageId,
Value,
}
#[derive(Iden)]
pub enum PackageConflicts {
Table,
PackageId,
Value,
}
#[derive(Iden)]
pub enum PackageProvides {
Table,
PackageId,
Value,
}
#[derive(Iden)]
pub enum PackageDepends {
Table, Table,
PackageId, PackageId,
Type, Type,
Value, Name,
} }
#[derive(Iden)] #[derive(Iden)]
pub enum PackageFile { pub enum PackageFile {
Table, Table,
PackageId, PackageId,
Value, Path,
} }

View File

@ -13,16 +13,22 @@ use migrator::Migrator;
type Result<T> = std::result::Result<T, sea_orm::DbErr>; type Result<T> = std::result::Result<T, sea_orm::DbErr>;
#[derive(EnumIter, DeriveActiveEnum, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)] #[derive(EnumIter, DeriveActiveEnum, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
#[sea_orm(rs_type = "String", db_type = "String(Some(6))")] #[sea_orm(rs_type = "i32", db_type = "Integer")]
pub enum PackageDepend { pub enum PackageRelatedEnum {
#[sea_orm(string_value = "depend")] #[sea_orm(num_value = 0)]
Conflicts,
#[sea_orm(num_value = 1)]
Replaces,
#[sea_orm(num_value = 2)]
Provides,
#[sea_orm(num_value = 3)]
Depend, Depend,
#[sea_orm(string_value = "make")] #[sea_orm(num_value = 4)]
Make, Makedepend,
#[sea_orm(string_value = "check")] #[sea_orm(num_value = 5)]
Check, Checkdepend,
#[sea_orm(string_value = "opt")] #[sea_orm(num_value = 6)]
Opt, Optdepend,
} }
#[derive(Serialize)] #[derive(Serialize)]
@ -31,9 +37,7 @@ pub struct FullPackage {
entry: package::Model, entry: package::Model,
licenses: Vec<String>, licenses: Vec<String>,
groups: Vec<String>, groups: Vec<String>,
replaces: Vec<String>, related: Vec<(PackageRelatedEnum, String)>,
provides: Vec<String>,
depends: Vec<(PackageDepend, String)>,
files: Vec<String>, files: Vec<String>,
} }

View File

@ -71,7 +71,7 @@ impl PackageQuery {
c_size: Set(info.csize), c_size: Set(info.csize),
description: Set(info.description), description: Set(info.description),
url: Set(info.url), url: Set(info.url),
build_date: Set(info.build_date), build_date: Set(info.build_date.to_string()),
packager: Set(info.packager), packager: Set(info.packager),
pgp_sig: Set(info.pgpsig), pgp_sig: Set(info.pgpsig),
pgp_sig_size: Set(info.pgpsigsize), pgp_sig_size: Set(info.pgpsigsize),
@ -83,7 +83,7 @@ impl PackageQuery {
// Insert all the related tables // Insert all the related tables
PackageLicense::insert_many(info.licenses.iter().map(|s| package_license::ActiveModel { PackageLicense::insert_many(info.licenses.iter().map(|s| package_license::ActiveModel {
package_id: Set(pkg_entry.id), package_id: Set(pkg_entry.id),
value: Set(s.to_string()), name: Set(s.to_string()),
})) }))
.on_empty_do_nothing() .on_empty_do_nothing()
.exec(&self.conn) .exec(&self.conn)
@ -91,64 +91,57 @@ impl PackageQuery {
PackageGroup::insert_many(info.groups.iter().map(|s| package_group::ActiveModel { PackageGroup::insert_many(info.groups.iter().map(|s| package_group::ActiveModel {
package_id: Set(pkg_entry.id), package_id: Set(pkg_entry.id),
value: Set(s.to_string()), name: Set(s.to_string()),
})) }))
.on_empty_do_nothing() .on_empty_do_nothing()
.exec(&self.conn) .exec(&self.conn)
.await?; .await?;
PackageReplaces::insert_many(info.replaces.iter().map(|s| package_replaces::ActiveModel { let related = info
package_id: Set(pkg_entry.id), .conflicts
value: Set(s.to_string()), .iter()
})) .map(|s| (PackageRelatedEnum::Conflicts, s))
.on_empty_do_nothing() .chain(
.exec(&self.conn) info.replaces
.await?; .iter()
.map(|s| (PackageRelatedEnum::Replaces, s)),
)
.chain(
info.provides
.iter()
.map(|s| (PackageRelatedEnum::Provides, s)),
)
.chain(info.depends.iter().map(|s| (PackageRelatedEnum::Depend, s)))
.chain(
info.makedepends
.iter()
.map(|s| (PackageRelatedEnum::Depend, s)),
)
.chain(
info.checkdepends
.iter()
.map(|s| (PackageRelatedEnum::Checkdepend, s)),
)
.chain(
info.optdepends
.iter()
.map(|s| (PackageRelatedEnum::Optdepend, s)),
);
PackageConflicts::insert_many(info.conflicts.iter().map(|s| { PackageRelated::insert_many(related.map(|(t, s)| package_related::ActiveModel {
package_conflicts::ActiveModel {
package_id: Set(pkg_entry.id), package_id: Set(pkg_entry.id),
value: Set(s.to_string()), r#type: Set(t),
} name: Set(s.to_string()),
})) }));
.on_empty_do_nothing()
.exec(&self.conn)
.await?;
PackageProvides::insert_many(info.provides.iter().map(|s| package_provides::ActiveModel {
package_id: Set(pkg_entry.id),
value: Set(s.to_string()),
}))
.on_empty_do_nothing()
.exec(&self.conn)
.await?;
PackageFile::insert_many(pkg.files.iter().map(|s| package_file::ActiveModel { PackageFile::insert_many(pkg.files.iter().map(|s| package_file::ActiveModel {
package_id: Set(pkg_entry.id), package_id: Set(pkg_entry.id),
value: Set(s.display().to_string()), path: Set(s.display().to_string()),
})) }))
.on_empty_do_nothing() .on_empty_do_nothing()
.exec(&self.conn) .exec(&self.conn)
.await?; .await?;
let deps = info
.depends
.iter()
.map(|d| (PackageDepend::Depend, d))
.chain(info.makedepends.iter().map(|d| (PackageDepend::Make, d)))
.chain(info.checkdepends.iter().map(|d| (PackageDepend::Check, d)))
.chain(info.optdepends.iter().map(|d| (PackageDepend::Opt, d)))
.map(|(t, s)| package_depends::ActiveModel {
package_id: Set(pkg_entry.id),
r#type: Set(t),
value: Set(s.to_string()),
});
PackageDepends::insert_many(deps)
.on_empty_do_nothing()
.exec(&self.conn)
.await?;
Ok(()) Ok(())
} }
@ -159,51 +152,35 @@ impl PackageQuery {
.all(&self.conn) .all(&self.conn)
.await? .await?
.into_iter() .into_iter()
.map(|e| e.value) .map(|e| e.name)
.collect(); .collect();
let groups = entry let groups = entry
.find_related(PackageGroup) .find_related(PackageGroup)
.all(&self.conn) .all(&self.conn)
.await? .await?
.into_iter() .into_iter()
.map(|e| e.value) .map(|e| e.name)
.collect(); .collect();
let replaces = entry let related = entry
.find_related(PackageReplaces) .find_related(PackageRelated)
.all(&self.conn) .all(&self.conn)
.await? .await?
.into_iter() .into_iter()
.map(|e| e.value) .map(|e| (e.r#type, e.name))
.collect();
let provides = entry
.find_related(PackageProvides)
.all(&self.conn)
.await?
.into_iter()
.map(|e| e.value)
.collect();
let depends = entry
.find_related(PackageDepends)
.all(&self.conn)
.await?
.into_iter()
.map(|e| (e.r#type, e.value))
.collect(); .collect();
let files = entry let files = entry
.find_related(PackageFile) .find_related(PackageFile)
.all(&self.conn) .all(&self.conn)
.await? .await?
.into_iter() .into_iter()
.map(|e| e.value) .map(|e| e.path)
.collect(); .collect();
Ok(Some(FullPackage { Ok(Some(FullPackage {
entry, entry,
licenses, licenses,
groups, groups,
replaces, related,
provides,
depends,
files, files,
})) }))
} else { } else {

View File

@ -281,7 +281,7 @@ impl From<Package> for package::ActiveModel {
c_size: Set(info.csize), c_size: Set(info.csize),
description: Set(info.description), description: Set(info.description),
url: Set(info.url), url: Set(info.url),
build_date: Set(info.build_date), build_date: Set(info.build_date.to_string()),
packager: Set(info.packager), packager: Set(info.packager),
pgp_sig: Set(info.pgpsig), pgp_sig: Set(info.pgpsig),
pgp_sig_size: Set(info.pgpsigsize), pgp_sig_size: Set(info.pgpsigsize),