Skip to content

Commit

Permalink
use v2 scheduler+new timezone handling by default for new users
Browse files Browse the repository at this point in the history
- In corner cases, enabling the new timezone handling later can cause
reviews to shift forward or back a day, so it's best to have it on
by default.
- ankidroid/Anki-Android#5805 has not landed
in a stable release yet, but will hopefully not be too far off by the
time 2.1.41 is released.
- Existing users will be unaffected, as the upgrade prompt in the previous
commit asks them if they use AnkiDroid.
- Users starting on AnkiDroid will be unaffected, as their collections
will still be on V1.
- The error message AnkiWeb gives when syncing an older AnkiDroid
with the new timezone enabled has been updated to direct users to the
preferences screen.
  • Loading branch information
dae committed Feb 21, 2021
1 parent 5ae66af commit 8372931
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions pylib/tests/test_schedv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def getEmptyCol():
col = getEmptyColOrig()
# only safe in test environment
col.set_config("schedVer", 1)
col._loadScheduler()
return col


Expand Down
5 changes: 3 additions & 2 deletions rslib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use slog::warn;
/// 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,
Expand All @@ -33,7 +33,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()
}
Expand Down
9 changes: 7 additions & 2 deletions rslib/src/storage/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::config::schema11_config_as_string;
use crate::err::Result;
use crate::err::{AnkiError, DBErrorKind};
use crate::timestamp::{TimestampMillis, TimestampSecs};
use crate::{config::schema11_config_as_string, sched::cutoff::local_minutes_west_for_stamp};
use crate::{i18n::I18n, sched::cutoff::v1_creation_date, text::without_combining};
use regex::Regex;
use rusqlite::{functions::FunctionFlags, params, Connection, NO_PARAMS};
Expand Down Expand Up @@ -166,13 +166,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)
],
)?;
}
Expand Down

0 comments on commit 8372931

Please sign in to comment.