Skip to content

Commit

Permalink
Merge pull request #9 from CoLearn-Dev/issue-7
Browse files Browse the repository at this point in the history
- support protocol package
  • Loading branch information
stneng authored May 19, 2022
2 parents 367cbf1 + 773e3d1 commit b3e886d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "colink-server"
version = "0.1.1"
version = "0.1.2"
edition = "2021"

[dependencies]
Expand Down
26 changes: 24 additions & 2 deletions src/service/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,18 @@ impl crate::server::MyService {
}

async fn remove_task_old_status(&self, user_id: &str, task: &Task) -> Result<(), Status> {
let list_key = format!("protocols:{}:{}", task.protocol_name, task.status);
let protocol_key = if task.status != "started" {
task.protocol_name.clone()
} else {
let mut ptype = "";
for p in &task.participants {
if p.user_id == user_id {
ptype = &p.ptype;
}
}
format!("{}:{}", task.protocol_name, ptype)
};
let list_key = format!("protocols:{}:{}", protocol_key, task.status);
self.remove_task_from_list_in_storage(user_id, task, &list_key)
.await?;
let list_key = format!("tasks:status:{}", task.status);
Expand Down Expand Up @@ -406,7 +417,18 @@ impl crate::server::MyService {
}

async fn add_task_new_status(&self, user_id: &str, task: &Task) -> Result<(), Status> {
let list_key = format!("protocols:{}:{}", task.protocol_name, task.status);
let protocol_key = if task.status != "started" {
task.protocol_name.clone()
} else {
let mut ptype = "";
for p in &task.participants {
if p.user_id == user_id {
ptype = &p.ptype;
}
}
format!("{}:{}", task.protocol_name, ptype)
};
let list_key = format!("protocols:{}:{}", protocol_key, task.status);
self.add_task_to_list_in_storage(user_id, task, &list_key)
.await?;
let list_key = format!("tasks:status:{}", task.status);
Expand Down
4 changes: 2 additions & 2 deletions tests/pull-and-build-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
set -e
rm -rf sdk-a
rm -rf sdk-p
git clone --recursive git@github.com:CoLearn-Dev/colink-sdk-a-rust-dev.git -b v0.1.0 sdk-a
git clone --recursive git@github.com:CoLearn-Dev/colink-sdk-p-rust-dev.git -b v0.1.0 sdk-p
git clone --recursive git@github.com:CoLearn-Dev/colink-sdk-a-rust-dev.git -b v0.1.1 sdk-a
git clone --recursive git@github.com:CoLearn-Dev/colink-sdk-p-rust-dev.git -b v0.1.2 sdk-p
cd sdk-a
cargo build --all-targets
cd ..
Expand Down

0 comments on commit b3e886d

Please sign in to comment.