Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono & ui] replace mr id with mr_link in ui #576

Merged
merged 1 commit into from
Sep 10, 2024
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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ taurus = { path = "taurus" }
mega = { path = "mega" }
mono = { path = "mono" }

anyhow = "1.0.86"
serde = "1.0.205"
anyhow = "1.0.87"
serde = "1.0.210"
serde_json = "1.0.128"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
Expand All @@ -44,7 +44,7 @@ thiserror = "1.0.63"
rand = "0.8.5"
smallvec = "1.13.2"
tokio = "1.40.0"
tokio-stream = "0.1.15"
tokio-stream = "0.1.16"
tokio-test = "0.4.4"
clap = "4.5.17"
async-trait = "0.1.82"
Expand All @@ -63,7 +63,7 @@ axum = "0.7.5"
axum-extra = "0.9.3"
axum-server = "0.7"
tower-http = "0.5.2"
tower = "0.5.0"
tower = "0.5.1"
hex = "0.4.3"
sea-orm = "1.0.1"
flate2 = "1.0.30"
Expand All @@ -73,7 +73,7 @@ idgenerator = "2.0.0"
num_cpus = "1.16.0"
config = "0.14.0"
shadow-rs = "0.34.0"
reqwest = "0.12.5"
reqwest = "0.12.7"
lazy_static = "1.5.0"
uuid = "1.10.0"
regex = "1.10.4"
Expand Down
16 changes: 8 additions & 8 deletions ceres/src/api_service/mono_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,21 @@ impl MonoApiService {
Ok(mr_list.into_iter().map(|m| m.into()).collect())
}

pub async fn mr_detail(&self, mr_id: i64) -> Result<Option<MRDetail>, MegaError> {
pub async fn mr_detail(&self, mr_link: &str) -> Result<Option<MRDetail>, MegaError> {
let storage = self.context.services.mono_storage.clone();
let model = storage.get_mr(mr_id).await.unwrap();
let model = storage.get_mr(mr_link).await.unwrap();
if let Some(model) = model {
let mut detail: MRDetail = model.into();
let conversions = storage.get_mr_conversations(mr_id).await.unwrap();
let conversions = storage.get_mr_conversations(mr_link).await.unwrap();
detail.conversions = conversions.into_iter().map(|x| x.into()).collect();
return Ok(Some(detail));
}
Ok(None)
}

pub async fn mr_tree_files(&self, mr_id: i64) -> Result<Vec<PathBuf>, MegaError> {
pub async fn mr_tree_files(&self, mr_link: &str) -> Result<Vec<PathBuf>, MegaError> {
let storage = self.context.services.mono_storage.clone();
let model = storage.get_mr(mr_id).await.unwrap();
let model = storage.get_mr(mr_link).await.unwrap();
if let Some(model) = model {
let to_tree_id = storage
.get_commit_by_hash(&model.to_hash)
Expand Down Expand Up @@ -281,9 +281,9 @@ impl MonoApiService {
Err(MegaError::with_message("Can not find related MR by id"))
}

pub async fn merge_mr(&self, mr_id: i64) -> Result<(), MegaError> {
pub async fn merge_mr(&self, mr_link: &str) -> Result<(), MegaError> {
let storage = self.context.services.mono_storage.clone();
if let Some(model) = storage.get_open_mr_by_id(mr_id).await.unwrap() {
if let Some(model) = storage.get_open_mr_by_link(mr_link).await.unwrap() {
let mut mr: MergeRequest = model.into();
let refs = storage.get_ref(&mr.path).await.unwrap().unwrap();

Expand All @@ -301,7 +301,7 @@ impl MonoApiService {

// add conversation
storage
.add_mr_conversation(mr.id, 0, ConvType::Merged)
.add_mr_conversation(&mr.mr_link, 0, ConvType::Merged)
.await
.unwrap();
if mr.path != "/" {
Expand Down
6 changes: 4 additions & 2 deletions ceres/src/model/mr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use callisto::{mega_mr, mega_mr_conv};

#[derive(Serialize, Deserialize)]
pub struct MrInfoItem {
pub id: i64,
pub mr_link: String,
pub title: String,
pub status: String,
pub open_timestamp: i64,
Expand All @@ -14,7 +14,7 @@ pub struct MrInfoItem {
impl From<mega_mr::Model> for MrInfoItem {
fn from(value: mega_mr::Model) -> Self {
Self {
id: value.id,
mr_link: value.mr_link,
title: String::new(),
status: value.status.to_string(),
open_timestamp: value.created_at.and_utc().timestamp(),
Expand All @@ -26,6 +26,7 @@ impl From<mega_mr::Model> for MrInfoItem {
#[derive(Serialize, Deserialize)]
pub struct MRDetail {
pub id: i64,
pub mr_link: String,
pub title: String,
pub status: String,
pub open_timestamp: i64,
Expand All @@ -45,6 +46,7 @@ impl From<mega_mr::Model> for MRDetail {
fn from(value: mega_mr::Model) -> Self {
Self {
id: value.id,
mr_link: value.mr_link,
title: String::new(),
status: value.status.to_string(),
open_timestamp: value.created_at.and_utc().timestamp(),
Expand Down
176 changes: 0 additions & 176 deletions ceres/src/pack/handler.rs

This file was deleted.

4 changes: 2 additions & 2 deletions ceres/src/pack/import_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use callisto::{mega_tree, raw_blob};
use common::errors::MegaError;
use jupiter::{
context::Context,
storage::{batch_save_model},
storage::batch_save_model,
};
use mercury::{
errors::GitError,
Expand All @@ -30,7 +30,7 @@ use mercury::{hash::SHA1, internal::pack::encode::PackEncoder};

use crate::{
api_service::{mono_api_service::MonoApiService, ApiHandler},
pack::handler::PackHandler, protocol::{import_refs::{CommandType, RefCommand, Refs}, repo::Repo},
pack::PackHandler, protocol::{import_refs::{CommandType, RefCommand, Refs}, repo::Repo},
};

pub struct ImportRepo {
Expand Down
Loading
Loading