Skip to content

Commit 0c4f176

Browse files
author
ljl
committed
Merge branch 'main' of https://github.com/ideal-world/bios
2 parents 5f93dc0 + db916ef commit 0c4f176

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

backend/middlewares/flow/src/api/cc/flow_cc_inst_api.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,8 @@ impl FlowCcInstApi {
153153
ctx: TardisContextExtractor,
154154
_request: &Request,
155155
) -> TardisApiResult<Void> {
156-
let mut funs = flow_constants::get_tardis_inst();
157-
funs.begin().await?;
158156
let vars = HashMap::from([("current_assigned".to_string(), Value::String(modify_req.0.current_assigned))]);
159-
FlowInstServ::modify_current_vars(&flow_inst_id.0, &vars, &funs, &ctx.0).await?;
160-
funs.commit().await?;
157+
FlowInstServ::modify_current_vars(&flow_inst_id.0, &vars, &ctx.0).await?;
161158
TardisResp::ok(Void {})
162159
}
163160

@@ -172,9 +169,7 @@ impl FlowCcInstApi {
172169
_request: &Request,
173170
) -> TardisApiResult<Void> {
174171
let mut funs = flow_constants::get_tardis_inst();
175-
funs.begin().await?;
176-
FlowInstServ::modify_current_vars(&flow_inst_id.0, &modify_req.0.vars, &funs, &ctx.0).await?;
177-
funs.commit().await?;
172+
FlowInstServ::modify_current_vars(&flow_inst_id.0, &modify_req.0.vars, &ctx.0).await?;
178173
TardisResp::ok(Void {})
179174
}
180175
}

backend/middlewares/flow/src/api/ci/flow_ci_inst_api.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ impl FlowCiInstApi {
122122
mut ctx: TardisContextExtractor,
123123
request: &Request,
124124
) -> TardisApiResult<Void> {
125-
let mut funs = flow_constants::get_tardis_inst();
125+
let funs = flow_constants::get_tardis_inst();
126126
check_without_owner_and_unsafe_fill_ctx(request, &funs, &mut ctx.0)?;
127-
funs.begin().await?;
128127
let vars = HashMap::from([("assigned_to".to_string(), Value::String(modify_req.0.current_assigned))]);
129-
FlowInstServ::modify_current_vars(&flow_inst_id.0, &vars, &funs, &ctx.0).await?;
130-
funs.commit().await?;
128+
FlowInstServ::modify_current_vars(&flow_inst_id.0, &vars, &ctx.0).await?;
131129
TardisResp::ok(Void {})
132130
}
133131

@@ -140,11 +138,9 @@ impl FlowCiInstApi {
140138
mut ctx: TardisContextExtractor,
141139
request: &Request,
142140
) -> TardisApiResult<Void> {
143-
let mut funs = flow_constants::get_tardis_inst();
141+
let funs = flow_constants::get_tardis_inst();
144142
check_without_owner_and_unsafe_fill_ctx(request, &funs, &mut ctx.0)?;
145-
funs.begin().await?;
146-
FlowInstServ::modify_current_vars(&flow_inst_id.0, &modify_req.0.vars, &funs, &ctx.0).await?;
147-
funs.commit().await?;
143+
FlowInstServ::modify_current_vars(&flow_inst_id.0, &modify_req.0.vars, &ctx.0).await?;
148144
TardisResp::ok(Void {})
149145
}
150146

backend/middlewares/flow/src/serv/flow_inst_serv.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,10 @@ impl FlowInstServ {
11031103
}
11041104
}
11051105

1106-
pub async fn modify_current_vars(flow_inst_id: &str, current_vars: &HashMap<String, Value>, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> {
1107-
let flow_inst_detail = Self::get(flow_inst_id, funs, ctx).await?;
1106+
pub async fn modify_current_vars(flow_inst_id: &str, current_vars: &HashMap<String, Value>, ctx: &TardisContext) -> TardisResult<()> {
1107+
let mut funs = flow_constants::get_tardis_inst();
1108+
funs.begin().await?;
1109+
let flow_inst_detail = Self::get(flow_inst_id, &funs, ctx).await?;
11081110
let mut new_vars: HashMap<String, Value> = HashMap::new();
11091111
if let Some(old_current_vars) = &flow_inst_detail.current_vars {
11101112
new_vars.extend(old_current_vars.clone());
@@ -1116,7 +1118,9 @@ impl FlowInstServ {
11161118
..Default::default()
11171119
};
11181120
funs.db().update_one(flow_inst, ctx).await.unwrap();
1121+
funs.commit().await?;
11191122

1123+
let funs = flow_constants::get_tardis_inst();
11201124
if let Some(ws_client) = ws_flow_client().await {
11211125
ws_client
11221126
.publish_front_change(
@@ -1127,7 +1131,7 @@ impl FlowInstServ {
11271131
)
11281132
.await?;
11291133
} else {
1130-
FlowEventServ::do_front_change(flow_inst_id, ctx, funs).await?;
1134+
FlowEventServ::do_front_change(flow_inst_id, ctx, &funs).await?;
11311135
}
11321136

11331137
Ok(())
@@ -1214,7 +1218,6 @@ impl FlowInstServ {
12141218
Self::modify_current_vars(
12151219
&flow_inst.id,
12161220
&TardisFuns::json.json_to_obj::<HashMap<String, Value>>(new_vars).unwrap_or_default(),
1217-
funs,
12181221
&ctx,
12191222
)
12201223
.await?;
@@ -1228,7 +1231,7 @@ impl FlowInstServ {
12281231
let mut current_vars = Self::get(inst_id, funs, ctx).await?.current_vars;
12291232
if current_vars.is_none() || !current_vars.clone().unwrap_or_default().contains_key(key) {
12301233
let new_vars = Self::get_new_vars(inst_id, funs, ctx).await?;
1231-
Self::modify_current_vars(inst_id, &TardisFuns::json.json_to_obj::<HashMap<String, Value>>(new_vars).unwrap_or_default(), funs, ctx).await?;
1234+
Self::modify_current_vars(inst_id, &TardisFuns::json.json_to_obj::<HashMap<String, Value>>(new_vars).unwrap_or_default(), ctx).await?;
12321235
current_vars = Self::get(inst_id, funs, ctx).await?.current_vars;
12331236
}
12341237

backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ pub async fn add(add_req: &mut SearchItemAddReq, funs: &TardisFunsInst, ctx: &Ta
3838
params.push(Value::from(add_req.title.as_str()));
3939

4040
let pinyin_vec = to_pinyin_vec(add_req.title.as_str(), Pinyin::plain);
41+
let content = add_req.title.as_str().split(' ').last().unwrap_or_default();
4142
if add_req.title.chars().count() > funs.conf::<SearchConfig>().split_strategy_rule_config.specify_word_length.unwrap_or(30) {
4243
params.push(Value::from(format!(
43-
"{} {} {}",
44+
"{} {} {} {}",
4445
add_req.title.as_str(),
4546
pinyin_vec.clone().into_iter().map(|pinyin| pinyin.chars().next().unwrap_or_default()).join(""),
47+
generate_word_combinations_with_symbol(content, vec!["-", "_"]).join(" "),
4648
generate_word_combinations(pinyin_vec).join(" ")
4749
)));
4850
} else {
49-
let content = add_req.title.as_str().split(' ').last().unwrap_or_default();
5051
params.push(Value::from(format!(
5152
"{} {} {} {} {} {} {}",
5253
add_req.title.as_str(),
@@ -126,15 +127,16 @@ pub async fn modify(tag: &str, key: &str, modify_req: &mut SearchItemModifyReq,
126127
sql_sets.push(format!("title_tsv = to_tsvector('{word_combinations_way}', ${})", params.len() + 1));
127128

128129
let pinyin_vec = to_pinyin_vec(title, Pinyin::plain);
130+
let content = title.split(' ').last().unwrap_or_default();
129131
if title.chars().count() > funs.conf::<SearchConfig>().split_strategy_rule_config.specify_word_length.unwrap_or(30) {
130132
params.push(Value::from(format!(
131-
"{} {} {}",
133+
"{} {} {} {}",
132134
title,
133135
pinyin_vec.clone().into_iter().map(|pinyin| pinyin.chars().next().unwrap_or_default()).join(""),
136+
generate_word_combinations_with_symbol(content, vec!["-", "_"]).join(" "),
134137
generate_word_combinations(pinyin_vec).join(" ")
135138
)));
136139
} else {
137-
let content = title.split(' ').last().unwrap_or_default();
138140
params.push(Value::from(format!(
139141
"{} {} {} {} {} {} {}",
140142
title,

0 commit comments

Comments
 (0)