default to the v2 scheduler in new collections

ported from 53d9433d94
This commit is contained in:
Damien Elmes 2021-05-06 19:07:31 +10:00
parent fc2d3ba07c
commit d878de54c0
3 changed files with 11 additions and 4 deletions

View File

@ -15,6 +15,7 @@ def getEmptyCol() -> Collection:
col = getEmptyColOrig()
# only safe in test environment
col.set_config("schedVer", 1)
col._loadScheduler()
return col

View File

@ -7,7 +7,7 @@ use serde_json::json;
/// new config variables, you do not need to add them here -
/// just create an accessor function below with an appropriate
/// default on missing/invalid values instead.
pub(crate) fn schema11_config_as_string() -> String {
pub(crate) fn schema11_config_as_string(creation_offset: Option<i32>) -> String {
let obj = json!({
"activeDecks": [1],
"curDeck": 1,
@ -22,7 +22,8 @@ pub(crate) fn schema11_config_as_string() -> String {
"sortBackwards": false,
"addToCur": true,
"dayLearnFirst": false,
"schedVer": 1,
"schedVer": 2,
"creationOffset": creation_offset,
});
serde_json::to_string(&obj).unwrap()
}

View File

@ -12,7 +12,7 @@ use crate::{
config::schema11::schema11_config_as_string,
error::{AnkiError, DbErrorKind, Result},
i18n::I18n,
scheduler::timing::v1_creation_date,
scheduler::timing::{local_minutes_west_for_stamp, v1_creation_date},
text::without_combining,
timestamp::TimestampMillis,
};
@ -168,13 +168,18 @@ impl SqliteStorage {
db.execute_batch(include_str!("schema11.sql"))?;
// start at schema 11, then upgrade below
let crt = v1_creation_date();
let offset = if server {
None
} else {
Some(local_minutes_west_for_stamp(crt))
};
db.execute(
"update col set crt=?, scm=?, ver=?, conf=?",
params![
crt,
TimestampMillis::now(),
SCHEMA_STARTING_VERSION,
&schema11_config_as_string()
&schema11_config_as_string(offset)
],
)?;
}