mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
Скачивание XLS документа по ссылке
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use schedule_parser::parse_xls;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn bench_parse_xls(c: &mut Criterion) {
|
||||
c.bench_function("parse_xls", |b| {
|
||||
b.iter(|| parse_xls(Path::new("../../schedule.xls")))
|
||||
});
|
||||
let buffer: Vec<u8> = include_bytes!("../../../schedule.xls").to_vec();
|
||||
|
||||
c.bench_function("parse_xls", |b| b.iter(|| parse_xls(&buffer)));
|
||||
}
|
||||
|
||||
criterion_group!(benches, bench_parse_xls);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crate::LessonParseResult::{Lessons, Street};
|
||||
use crate::schema::LessonType::Break;
|
||||
use crate::schema::{Day, Lesson, LessonSubGroup, LessonTime, LessonType, ScheduleEntity};
|
||||
use calamine::{Reader, Xls, open_workbook};
|
||||
use crate::LessonParseResult::{Lessons, Street};
|
||||
use calamine::{open_workbook_from_rs, Reader, Xls};
|
||||
use chrono::{Duration, NaiveDateTime};
|
||||
use fuzzy_matcher::FuzzyMatcher;
|
||||
use fuzzy_matcher::skim::SkimMatcherV2;
|
||||
use fuzzy_matcher::FuzzyMatcher;
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::io::Cursor;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
mod schema;
|
||||
@@ -539,12 +539,13 @@ fn convert_groups_to_teachers(
|
||||
}
|
||||
|
||||
pub fn parse_xls(
|
||||
path: &Path,
|
||||
buffer: &Vec<u8>,
|
||||
) -> (
|
||||
HashMap<String, ScheduleEntity>,
|
||||
HashMap<String, ScheduleEntity>,
|
||||
) {
|
||||
let mut workbook: Xls<_> = open_workbook(path).expect("Can't open workbook");
|
||||
let cursor = Cursor::new(&buffer);
|
||||
let mut workbook: Xls<_> = open_workbook_from_rs(cursor).expect("Can't open workbook");
|
||||
|
||||
let worksheet: WorkSheet = workbook
|
||||
.worksheets()
|
||||
@@ -693,9 +694,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = parse_xls(Path::new("../../schedule.xls"));
|
||||
|
||||
fn read() {
|
||||
let buffer: Vec<u8> = include_bytes!("../../../../schedule.xls").to_vec();
|
||||
let result = parse_xls(&buffer);
|
||||
|
||||
assert_ne!(result.0.len(), 0);
|
||||
assert_ne!(result.1.len(), 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user