Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ qdrant-client = "1.7"
walkdir = "2.4"
dagrs = "0.5.0"
tar = "0.4"

indexmap = "2.10.0"
envsubst = "0.2.1"
rcgen = "0.13.2"
diffs = "0.5.1"
Expand Down
1 change: 1 addition & 0 deletions jupiter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ aws-config = { workspace = true, features = ["behavior-version-latest"] }
aws-sdk-s3 = { workspace = true, features = ["rt-tokio"] }
anyhow = { workspace = true }
tempfile = { workspace = true }
indexmap = { workspace = true }
36 changes: 36 additions & 0 deletions jupiter/callisto/src/entity_ext/item_assignees.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use sea_orm::entity::prelude::*;

use crate::{item_assignees::Column, item_assignees::Entity};

#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
MegaIssue,
MegaMr,
}

impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::MegaIssue => Entity::belongs_to(crate::mega_issue::Entity)
.from(Column::ItemId)
.to(crate::mega_issue::Column::Id)
.into(),
Self::MegaMr => Entity::belongs_to(crate::mega_mr::Entity)
.from(Column::ItemId)
.to(crate::mega_mr::Column::Id)
.into(),
}
}
}

impl Related<crate::mega_issue::Entity> for Entity {
fn to() -> RelationDef {
Relation::MegaIssue.def()
}
}

impl Related<crate::mega_mr::Entity> for Entity {
fn to() -> RelationDef {
Relation::MegaMr.def()
}
}
36 changes: 36 additions & 0 deletions jupiter/callisto/src/entity_ext/mega_conversation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use sea_orm::entity::prelude::*;

use crate::{mega_conversation::Column, mega_conversation::Entity};

#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
MegaIssue,
MegaMr,
}

impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::MegaIssue => Entity::belongs_to(crate::mega_issue::Entity)
.from(Column::Link)
.to(crate::mega_issue::Column::Link)
.into(),
Self::MegaMr => Entity::belongs_to(crate::mega_mr::Entity)
.from(Column::Link)
.to(crate::mega_mr::Column::Link)
.into(),
}
}
}

impl Related<crate::mega_issue::Entity> for Entity {
fn to() -> RelationDef {
Relation::MegaIssue.def()
}
}

impl Related<crate::mega_mr::Entity> for Entity {
fn to() -> RelationDef {
Relation::MegaMr.def()
}
}
34 changes: 30 additions & 4 deletions jupiter/callisto/src/entity_ext/mega_issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ use crate::mega_issue::Entity;

#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
Label,
ItemLabels,
ItemAssignees,
Conversation,
}

impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::Label => Entity::has_many(crate::item_labels::Entity).into(),
Self::ItemLabels => Entity::has_many(crate::item_labels::Entity).into(),
Self::ItemAssignees => Entity::has_many(crate::item_assignees::Entity).into(),
Self::Conversation => Entity::has_many(crate::mega_conversation::Entity).into(),
}
}
}
Expand All @@ -21,6 +25,28 @@ impl Related<crate::label::Entity> for Entity {
}

fn via() -> Option<RelationDef> {
Some(crate::entity_ext::item_labels::Relation::MegaIssue.def().rev())
Some(
crate::entity_ext::item_labels::Relation::MegaIssue
.def()
.rev(),
)
}
}
}

impl Related<crate::item_assignees::Entity> for Entity {
fn to() -> RelationDef {
Relation::ItemAssignees.def()
}
fn via() -> Option<RelationDef> {
None
}
}

impl Related<crate::mega_conversation::Entity> for Entity {
fn to() -> RelationDef {
Relation::Conversation.def()
}
fn via() -> Option<RelationDef> {
None
}
}
26 changes: 24 additions & 2 deletions jupiter/callisto/src/entity_ext/mega_mr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ use crate::mega_mr::Entity;

#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
Label,
ItemLabels,
ItemAssignees,
Conversation,
}

impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::Label => Entity::has_many(crate::item_labels::Entity).into(),
Self::ItemLabels => Entity::has_many(crate::item_labels::Entity).into(),
Self::ItemAssignees => Entity::has_many(crate::item_assignees::Entity).into(),
Self::Conversation => Entity::has_many(crate::mega_conversation::Entity).into(),
}
}
}
Expand All @@ -24,3 +28,21 @@ impl Related<crate::label::Entity> for Entity {
Some(crate::entity_ext::item_labels::Relation::MegaMr.def().rev())
}
}

impl Related<crate::item_assignees::Entity> for Entity {
fn to() -> RelationDef {
Relation::ItemAssignees.def()
}
fn via() -> Option<RelationDef> {
None
}
}

impl Related<crate::mega_conversation::Entity> for Entity {
fn to() -> RelationDef {
Relation::Conversation.def()
}
fn via() -> Option<RelationDef> {
None
}
}
6 changes: 4 additions & 2 deletions jupiter/callisto/src/entity_ext/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod item_assignees;
pub mod item_labels;
pub mod label;
pub mod mega_issue;
pub mod mega_mr;
pub mod item_labels;
pub mod label;
pub mod mega_conversation;
21 changes: 21 additions & 0 deletions jupiter/callisto/src/item_assignees.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.12

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "item_assignees")]
pub struct Model {
pub created_at: DateTime,
pub updated_at: DateTime,
#[sea_orm(primary_key, auto_increment = false)]
pub item_id: i64,
#[sea_orm(primary_key, auto_increment = false)]
pub assignnee_id: String,
pub item_type: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
2 changes: 1 addition & 1 deletion jupiter/callisto/src/mega_issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Model {
pub created_at: DateTime,
pub updated_at: DateTime,
pub closed_at: Option<DateTime>,
pub user_id: String,
pub author: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
1 change: 1 addition & 0 deletions jupiter/callisto/src/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod git_repo;
pub mod git_tag;
pub mod git_tree;
pub mod import_refs;
pub mod item_assignees;
pub mod item_labels;
pub mod label;
pub mod lfs_locks;
Expand Down
1 change: 1 addition & 0 deletions jupiter/callisto/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub use super::git_repo::Entity as GitRepo;
pub use super::git_tag::Entity as GitTag;
pub use super::git_tree::Entity as GitTree;
pub use super::import_refs::Entity as ImportRefs;
pub use super::item_assignees::Entity as ItemAssignees;
pub use super::item_labels::Entity as ItemLabels;
pub use super::label::Entity as Label;
pub use super::lfs_locks::Entity as LfsLocks;
Expand Down
2 changes: 2 additions & 0 deletions jupiter/callisto/src/sea_orm_active_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub enum ConvTypeEnum {
Reopen,
#[sea_orm(string_value = "label")]
Label,
#[sea_orm(string_value = "assignee")]
Assignee,
}
#[derive(
Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ToSchema,
Expand Down
80 changes: 80 additions & 0 deletions jupiter/src/migration/m20250702_072055_add_item_assignees.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use sea_orm::DatabaseBackend;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let backend = manager.get_database_backend();

match backend {
DatabaseBackend::Postgres => {
manager
.get_connection()
.execute_unprepared(
r#"ALTER TYPE conv_type_enum ADD VALUE IF NOT EXISTS 'assignee';"#,
)
.await?;
}
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}
}

manager
.create_table(
table_auto(ItemAssignees::Table)
.col(big_integer(ItemAssignees::ItemId))
.col(string(ItemAssignees::AssignneeId))
.col(string(ItemAssignees::ItemType))
.primary_key(
Index::create()
.col(ItemAssignees::ItemId)
.col(ItemAssignees::AssignneeId),
)
.to_owned(),
)
.await?;

manager
.alter_table(
Table::alter()
.table(MegaIssue::Table)
.drop_column("user_id")
.to_owned(),
)
.await?;

manager
.alter_table(
Table::alter()
.table(MegaIssue::Table)
.add_column_if_not_exists(
ColumnDef::new(Alias::new("author"))
.string()
.not_null()
.default(""),
)
.to_owned(),
)
.await?;
Ok(())
}

async fn down(&self, _: &SchemaManager) -> Result<(), DbErr> {
Ok(())
}
}

#[derive(DeriveIden)]
enum ItemAssignees {
Table,
ItemId,
AssignneeId,
ItemType,
}

#[derive(DeriveIden)]
enum MegaIssue {
Table,
}
2 changes: 2 additions & 0 deletions jupiter/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod m20250610_000001_add_vault_storage;
mod m20250613_033821_alter_user_id;
mod m20250618_065050_add_label;
mod m20250628_025312_add_username_in_conversation;
mod m20250702_072055_add_item_assignees;

/// Creates a primary key column definition with big integer type.
///
Expand Down Expand Up @@ -72,6 +73,7 @@ impl MigratorTrait for Migrator {
Box::new(m20250613_033821_alter_user_id::Migration),
Box::new(m20250618_065050_add_label::Migration),
Box::new(m20250628_025312_add_username_in_conversation::Migration),
Box::new(m20250702_072055_add_item_assignees::Migration),
]
}
}
Expand Down
8 changes: 4 additions & 4 deletions jupiter/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ pub mod mq_storage;
pub mod mr_storage;
pub mod raw_db_storage;
pub mod relay_storage;
pub mod stg_common;
pub mod user_storage;
pub mod vault_storage;

use sea_orm::{sea_query::OnConflict, ActiveModelTrait, ConnectionTrait, DbErr, EntityTrait};

use common::errors::MegaError;

use std::sync::{Arc, LazyLock, Weak};

use sea_orm::{sea_query::OnConflict, ActiveModelTrait, ConnectionTrait, DbErr, EntityTrait};

use common::config::Config;
use common::errors::MegaError;

use crate::lfs_storage::{self, local_storage::LocalStorage, LfsFileStorage};
use crate::storage::init::database_connection;
Expand Down
Loading
Loading