forked from alemi/upub
feat!: remove published from some join tables
it was now() anyway just look object's published, this saves some space but i won't bother making a migration :p
This commit is contained in:
parent
5a4671f20d
commit
9822fc3f07
5 changed files with 2 additions and 30 deletions
|
@ -12,7 +12,6 @@ pub struct Model {
|
|||
pub document_type: DocumentType,
|
||||
pub name: Option<String>,
|
||||
pub media_type: String,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
@ -42,6 +41,5 @@ impl Model {
|
|||
.set_document_type(Some(self.document_type))
|
||||
.set_media_type(Some(&self.media_type))
|
||||
.set_name(self.name.as_deref())
|
||||
.set_published(Some(self.published))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ pub struct Model {
|
|||
pub internal: i64,
|
||||
pub object: i64,
|
||||
pub name: String,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -7,7 +7,6 @@ pub struct Model {
|
|||
pub internal: i64,
|
||||
pub object: i64,
|
||||
pub actor: String,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -25,7 +25,6 @@ pub trait Normalizer {
|
|||
impl Normalizer for crate::Context {
|
||||
|
||||
async fn insert_object(&self, object: impl apb::Object, tx: &impl ConnectionTrait) -> Result<crate::model::object::Model, NormalizerError> {
|
||||
let now = chrono::Utc::now();
|
||||
let mut object_model = AP::object(&object)?;
|
||||
|
||||
// make sure content only contains a safe subset of html
|
||||
|
@ -87,7 +86,6 @@ impl Normalizer for crate::Context {
|
|||
document_type: Set(apb::DocumentType::Page),
|
||||
name: Set(l.name().str()),
|
||||
media_type: Set(l.media_type().unwrap_or("link").to_string()),
|
||||
published: Set(now),
|
||||
},
|
||||
Node::Object(o) =>
|
||||
AP::attachment_q(o.as_document()?, object_model.internal, None)?,
|
||||
|
@ -133,7 +131,6 @@ impl Normalizer for crate::Context {
|
|||
internal: NotSet,
|
||||
object: Set(object_model.internal),
|
||||
actor: Set(l.href().to_string()),
|
||||
published: Set(now),
|
||||
};
|
||||
crate::model::mention::Entity::insert(model)
|
||||
.exec(tx)
|
||||
|
@ -147,7 +144,6 @@ impl Normalizer for crate::Context {
|
|||
internal: NotSet,
|
||||
object: Set(object_model.internal),
|
||||
name: Set(hashtag),
|
||||
published: Set(now),
|
||||
};
|
||||
crate::model::hashtag::Entity::insert(model)
|
||||
.exec(tx)
|
||||
|
@ -273,7 +269,6 @@ impl AP {
|
|||
document_type: document.as_document().map_or(apb::DocumentType::Document, |x| x.document_type().unwrap_or(apb::DocumentType::Page)),
|
||||
name: document.name().str(),
|
||||
media_type: document.media_type().unwrap_or("link").to_string(),
|
||||
published: document.published().unwrap_or_else(|_| chrono::Utc::now()),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ pub enum Attachments {
|
|||
Object,
|
||||
Name,
|
||||
MediaType,
|
||||
Published,
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
|
@ -20,7 +19,6 @@ pub enum Mentions {
|
|||
Internal,
|
||||
Object,
|
||||
Actor,
|
||||
Published,
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
|
@ -29,7 +27,6 @@ pub enum Hashtags {
|
|||
Internal,
|
||||
Object,
|
||||
Name,
|
||||
Published,
|
||||
}
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
|
@ -63,7 +60,6 @@ impl MigrationTrait for Migration {
|
|||
.col(ColumnDef::new(Attachments::DocumentType).string().not_null())
|
||||
.col(ColumnDef::new(Attachments::Name).string().null())
|
||||
.col(ColumnDef::new(Attachments::MediaType).string().not_null())
|
||||
.col(ColumnDef::new(Attachments::Published).timestamp_with_time_zone().not_null().default(Expr::current_timestamp()))
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
|
@ -116,14 +112,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("index-mentions-actor-published")
|
||||
.table(Mentions::Table)
|
||||
.col(Mentions::Actor)
|
||||
.col((Mentions::Published, IndexOrder::Desc))
|
||||
.to_owned()
|
||||
)
|
||||
.create_index(Index::create().name("index-mentions-actor").table(Mentions::Table).col(Mentions::Actor).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -148,7 +137,6 @@ impl MigrationTrait for Migration {
|
|||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Hashtags::Name).string().not_null())
|
||||
.col(ColumnDef::new(Hashtags::Published).timestamp_with_time_zone().not_null().default(Expr::current_timestamp()))
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
|
@ -158,14 +146,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("index-hashtags-name-published")
|
||||
.table(Hashtags::Table)
|
||||
.col(Hashtags::Name)
|
||||
.col((Hashtags::Published, IndexOrder::Desc))
|
||||
.to_owned()
|
||||
)
|
||||
.create_index(Index::create().name("index-hashtags-name").table(Hashtags::Table).col(Hashtags::Name).to_owned())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue