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
11 changes: 8 additions & 3 deletions extensions/rag/index/src/qdrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ impl QdrantNode {
log::info!("Collection '{}' already exists", self.collection_name);
}
Ok(false) => {
log::info!("Collection '{}' does not exist, creating...", self.collection_name);
log::info!(
"Collection '{}' does not exist, creating...",
self.collection_name
);
if let Err(e) = self
.client
.create_collection(
Expand All @@ -45,15 +48,17 @@ impl QdrantNode {
)
.await
{
log::error!("Failed to create collection '{}': {e}", self.collection_name);
log::error!(
"Failed to create collection '{}': {e}",
self.collection_name
);
}
}
Err(e) => {
log::error!("Failed to check collection existence: {e}");
}
}
}


// async fn ensure_collection(&self) {
// if self
Expand Down
35 changes: 24 additions & 11 deletions jupiter/callisto/src/builds.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.15

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand All @@ -7,21 +7,34 @@ use serde::{Deserialize, Serialize};
#[sea_orm(table_name = "builds")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub build_id: Uuid,
pub id: Uuid,
pub task_id: Uuid,
pub exit_code: Option<i32>,
pub start_at: DateTime,
pub end_at: Option<DateTime>,
pub repo_name: String,
pub start_at: DateTimeWithTimeZone,
pub end_at: Option<DateTimeWithTimeZone>,
pub repo: String,
pub target: String,
#[sea_orm(column_type = "Text")]
pub args: Option<Vec<String>>,
pub output_file: String,
#[sea_orm(column_type = "Text")]
pub arguments: String,
#[sea_orm(column_type = "Text")]
pub mr: String,
pub created_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
pub enum Relation {
#[sea_orm(
belongs_to = "super::tasks::Entity",
from = "Column::TaskId",
to = "super::tasks::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Tasks,
}

impl Related<super::tasks::Entity> for Entity {
fn to() -> RelationDef {
Relation::Tasks.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
1 change: 1 addition & 0 deletions jupiter/callisto/src/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod prelude;

pub mod access_token;
pub mod builds;
pub mod check_result;
pub mod entity_ext;
pub mod git_blob;
Expand Down
1 change: 1 addition & 0 deletions jupiter/callisto/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.15

pub use super::access_token::Entity as AccessToken;
pub use super::builds::Entity as Builds;
pub use super::check_result::Entity as CheckResult;
pub use super::git_blob::Entity as GitBlob;
pub use super::git_commit::Entity as GitCommit;
Expand Down
29 changes: 16 additions & 13 deletions jupiter/callisto/src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ use serde::{Deserialize, Serialize};
#[sea_orm(table_name = "tasks")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub task_id: Uuid,
#[sea_orm(column_type = "JsonBinary")]
pub build_ids: Json,
#[sea_orm(column_type = "JsonBinary")]
pub output_files: Json,
pub exit_code: Option<i32>,
pub start_at: DateTimeWithTimeZone,
pub end_at: Option<DateTimeWithTimeZone>,
pub repo_name: String,
pub target: String,
pub arguments: String,
pub mr: String,
pub id: Uuid,
pub mr_id: i64,
pub task_name: Option<String>,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub template: Option<Json>,
pub created_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
pub enum Relation {
#[sea_orm(has_many = "super::builds::Entity")]
Builds,
}

impl Related<super::builds::Entity> for Entity {
fn to() -> RelationDef {
Relation::Builds.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
128 changes: 128 additions & 0 deletions jupiter/src/migration/m20250904_074945_modify_tasks_and_builds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Tasks::Table).to_owned())
.await?;
manager
.create_table(
Table::create()
.table(Tasks::Table)
.if_not_exists()
.col(ColumnDef::new(Tasks::Id).uuid().not_null().primary_key())
.col(ColumnDef::new(Tasks::MrId).big_integer().not_null())
.col(ColumnDef::new(Tasks::TaskName).string())
.col(ColumnDef::new(Tasks::Template).json_binary())
Comment thread
slow2342 marked this conversation as resolved.
.col(
ColumnDef::new(Tasks::CreatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.if_not_exists()
.name("idx_tasks_created_at")
.table(Tasks::Table)
.col(Tasks::CreatedAt)
.to_owned(),
)
.await?;

manager
.create_table(
Table::create()
.table(Builds::Table)
.if_not_exists()
.col(ColumnDef::new(Builds::Id).uuid().not_null().primary_key())
.col(ColumnDef::new(Builds::TaskId).uuid().not_null())
.col(ColumnDef::new(Builds::ExitCode).integer())
.col(
ColumnDef::new(Builds::StartAt)
.timestamp_with_time_zone()
.not_null(),
)
.col(ColumnDef::new(Builds::EndAt).timestamp_with_time_zone())
.col(ColumnDef::new(Builds::Repo).string().not_null())
.col(ColumnDef::new(Builds::Target).string().not_null())
.col(ColumnDef::new(Builds::Args).json_binary())
.col(ColumnDef::new(Builds::OutputFile).string().not_null())
.col(
ColumnDef::new(Builds::CreatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.foreign_key(
ForeignKey::create()
.name("fk_builds_task_id")
.from(Builds::Table, Builds::TaskId)
.to(Tasks::Table, Tasks::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.if_not_exists()
.name("idx_builds_task_id")
.table(Builds::Table)
.col(Builds::TaskId)
.to_owned(),
)
.await?;

manager
.create_index(
Index::create()
.if_not_exists()
.name("idx_builds_start_at")
.table(Builds::Table)
.col(Builds::StartAt)
.to_owned(),
)
.await?;

Ok(())
}

async fn down(&self, _: &SchemaManager) -> Result<(), DbErr> {
Ok(())
}
Comment thread
benjamin-747 marked this conversation as resolved.
}

#[derive(DeriveIden)]
enum Tasks {
Table,
Id,
MrId,
TaskName,
Template,
CreatedAt,
}

#[derive(DeriveIden)]
enum Builds {
Table,
Id,
TaskId,
ExitCode,
StartAt,
EndAt,
Repo,
Target,
Args,
OutputFile,
CreatedAt,
}
3 changes: 2 additions & 1 deletion jupiter/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mod m20250828_092459_remove_gpg_table;
mod m20250828_092729_create_standalone_table;
mod m20250903_013904_create_task_table;
mod m20250903_071928_add_issue_refs;
mod m20250904_074945_modify_tasks_and_builds;
mod m20250905_163011_add_mr_reviewer;
/// Creates a primary key column definition with big integer type.
///
Expand Down Expand Up @@ -98,11 +99,11 @@ impl MigratorTrait for Migrator {
Box::new(m20250828_092729_create_standalone_table::Migration),
Box::new(m20250903_013904_create_task_table::Migration),
Box::new(m20250903_071928_add_issue_refs::Migration),
Box::new(m20250904_074945_modify_tasks_and_builds::Migration),
Box::new(m20250905_163011_add_mr_reviewer::Migration),
]
}
}

/// Applies database migrations to the given database connection.
///
/// # Arguments
Expand Down
25 changes: 14 additions & 11 deletions libra/examples/test_dry_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,41 @@ use tempfile::TempDir;

fn main() {
println!("Testing libra rm --dry-run functionality...");

// Create a temporary directory for test files
let temp_dir = TempDir::new().expect("Failed to create temporary directory");
let temp_path = temp_dir.path();

// Create test files in the temporary directory
let file1_path = temp_path.join("file1.txt");
let file2_path = temp_path.join("file2.txt");

let mut file1 = fs::File::create(&file1_path).unwrap();
file1.write_all(b"Test content 1").unwrap();

let mut file2 = fs::File::create(&file2_path).unwrap();
file2.write_all(b"Test content 2").unwrap();

println!("Created test files in temporary directory: {:?}", temp_path);

// Test dry-run functionality
let args = RemoveArgs {
pathspec: vec![file1_path.to_string_lossy().to_string(), file2_path.to_string_lossy().to_string()],
pathspec: vec![
file1_path.to_string_lossy().to_string(),
file2_path.to_string_lossy().to_string(),
],
cached: false,
recursive: false,
force: true, // Use force mode to avoid requiring git repository
dry_run: true,
};

println!("\nExecuting: libra rm --dry-run --force on test files");

match execute(args) {
Ok(_) => {
println!("✓ dry-run executed successfully!");

// Verify files still exist
if file1_path.exists() && file2_path.exists() {
println!(" Files still exist after dry-run (correct behavior)");
Expand All @@ -49,7 +52,7 @@ fn main() {
println!("✗ dry-run execution failed: {:?}", e);
}
}

println!("\nTest completed, temporary directory will be automatically cleaned up");
// The temporary directory will be automatically cleaned up when temp_dir goes out of scope
}
2 changes: 0 additions & 2 deletions libra/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ use std::io;
use std::io::Write;
use std::path::Path;



// impl load for all objects
pub fn load_object<T>(hash: &SHA1) -> Result<T, GitError>
where
Expand Down
Loading
Loading