Skip to content

Commit

Permalink
update deps.
Browse files Browse the repository at this point in the history
use stable channel.
  • Loading branch information
worksoup committed Nov 30, 2024
1 parent f20392d commit 2487ac9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

59 changes: 31 additions & 28 deletions src/cli/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ pub fn parse_location_sub_command(db: &DataBase, sub_command: LocationSubCommand
}
// 尝试将其解释为 `location_id`.
let location_id = location_str.trim().parse::<i64>();
if let Ok(location_id) = location_id
&& LocationTable::has_location(db, location_id)
if location_id
.as_ref()
.is_ok_and(|location_id| LocationTable::has_location(db, *location_id))
{
location_id
unsafe { location_id.unwrap_unchecked() }
}
// 无法解释为 `location_id` 则解释为别名。
else if AliasTable::has_alias(db, location_str.trim())
&& let Some(location_id) = AliasTable::get_location_id(db, location_str.trim())
else if let Some(location_id) =
AliasTable::get_location_id(db, location_str.trim())
{
location_id
} else {
Expand Down Expand Up @@ -194,16 +195,21 @@ pub fn parse_location_sub_command(db: &DataBase, sub_command: LocationSubCommand
let location_id = location_id.or_else(|| {
alias.and_then(|alias| AliasTable::get_location_id(db, &alias))
});
if let Some(location_id) = location_id
&& LocationTable::has_location(db, location_id)
{
LocationTable::delete_location(db, location_id);
let aliases = AliasTable::get_aliases(db, location_id);
for alias in aliases.iter() {
AliasTable::delete_alias(db, alias)
match location_id {
Some(location_id) => {
if LocationTable::has_location(db, location_id) {
LocationTable::delete_location(db, location_id);
let aliases = AliasTable::get_aliases(db, location_id);
for alias in aliases.iter() {
AliasTable::delete_alias(db, alias)
}
} else {
warn!("警告:未指定有效的位置,将不做任何事情。");
}
}
None => {
warn!("警告:未指定有效的位置,将不做任何事情。");
}
} else {
warn!("警告:未指定有效的位置,将不做任何事情。");
}
}
Remove::Aliases { alias } => {
Expand Down Expand Up @@ -327,19 +333,16 @@ pub fn parse_location_sub_command(db: &DataBase, sub_command: LocationSubCommand
}
do_something = true;
}
if let Some(course_id) = course
&& let Some(course) = {
let courses =
cxlib::types::Course::get_courses(AccountTable::get_sessions(db).values())
.unwrap_or_default()
.into_keys()
.map(|c| (c.get_id(), c))
.collect::<HashMap<_, _>>();
courses.get(&course_id).cloned()
}
{
course.and_then(|course_id| {
let courses =
cxlib::types::Course::get_courses(AccountTable::get_sessions(db).values())
.ok()?;
let course = courses
.into_iter()
.find(|(course, _)| course.get_id() == course_id)?
.0;
let sessions = AccountTable::get_sessions(db);
if let Some(session) = sessions.values().next() {
sessions.values().next().map(|session| {
match LocationWithRange::from_log(session, &course) {
Ok(locations) => {
if locations.is_empty() {
Expand All @@ -359,8 +362,8 @@ pub fn parse_location_sub_command(db: &DataBase, sub_command: LocationSubCommand
warn!("遇到了问题:{e}");
}
}
}
}
})
});
if !do_something {
warn!("未指定任何参数,不做任何事情。")
}
Expand Down
33 changes: 15 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#![feature(ascii_char)]
#![feature(async_closure)]
#![feature(hash_set_entry)]
#![feature(map_try_insert)]
#![feature(let_chains)]

mod cli;

// #[global_allocator]
Expand Down Expand Up @@ -249,19 +243,22 @@ pub fn run() {
.into_keys()
.map(|c| (c.get_id(), c))
.collect::<HashMap<_, _>>();
let (a, n) = if let Some(course) = courses.get(&course)
&& let Some(session) = sessions.values().next()
&& let Ok(a) = Activity::get_course_activities(&db, session, course)
{
a.into_iter()
.filter_map(|k| match k {
Activity::RawSign(k) => Some(k),
Activity::Other(_) => None,
let (a, n) = courses
.get(&course)
.and_then(|course| {
sessions.values().next().and_then(|session| {
Activity::get_course_activities(&db, session, course).ok()
})
.partition(|k| k.is_valid())
} else {
(vec![], vec![])
};
})
.map(|a| {
a.into_iter()
.filter_map(|k| match k {
Activity::RawSign(k) => Some(k),
Activity::Other(_) => None,
})
.partition(|k| k.is_valid())
})
.unwrap_or_else(|| (vec![], vec![]));
// 列出指定课程的有效签到。
for a in a {
if a.course.get_id() == course {
Expand Down

0 comments on commit 2487ac9

Please sign in to comment.