add switch in prefs for new timezone handling code; bump sync version

AD devs: before updating the sync version to 10, please make sure
the new timezone code has been ported over. The core change to the
scheduler is in _updateCutoff():

9736e4a970/pylib/anki/schedv2.py (L1357)

with the following supporting Python functions:

9736e4a970/pylib/anki/schedv2.py (L1410)

 _timing_today() is calculated in Rust (lines up to 92, the rest are
tests):

9736e4a970/rslib/src/sched/cutoff.rs (L20)

The change went through a few iterations before stabilising, so it's
probably easier to refer to the above code than the patches that got
us to that point.
This commit is contained in:
Damien Elmes 2020-03-10 17:50:18 +10:00
parent 9736e4a970
commit 131d37dca5
3 changed files with 21 additions and 2 deletions

View file

@ -71,7 +71,7 @@ SCHEMA_VERSION = 11
SYNC_ZIP_SIZE = int(2.5 * 1024 * 1024) SYNC_ZIP_SIZE = int(2.5 * 1024 * 1024)
SYNC_ZIP_COUNT = 25 SYNC_ZIP_COUNT = 25
SYNC_BASE = "https://sync%s.ankiweb.net/" SYNC_BASE = "https://sync%s.ankiweb.net/"
SYNC_VER = 9 SYNC_VER = 10
HELP_SITE = "https://apps.ankiweb.net/docs/manual.html" HELP_SITE = "https://apps.ankiweb.net/docs/manual.html"

View file

@ -92,8 +92,10 @@ class Preferences(QDialog):
f.dayLearnFirst.setChecked(qc.get("dayLearnFirst", False)) f.dayLearnFirst.setChecked(qc.get("dayLearnFirst", False))
if self.mw.col.schedVer() != 2: if self.mw.col.schedVer() != 2:
f.dayLearnFirst.setVisible(False) f.dayLearnFirst.setVisible(False)
f.new_timezone.setVisible(False)
else: else:
f.newSched.setChecked(True) f.newSched.setChecked(True)
f.new_timezone.setChecked(self.mw.col.sched._new_timezone_enabled())
def updateCollection(self): def updateCollection(self):
f = self.form f = self.form
@ -118,6 +120,14 @@ class Preferences(QDialog):
qc["addToCur"] = not f.useCurrent.currentIndex() qc["addToCur"] = not f.useCurrent.currentIndex()
qc["dayLearnFirst"] = f.dayLearnFirst.isChecked() qc["dayLearnFirst"] = f.dayLearnFirst.isChecked()
self._updateDayCutoff() self._updateDayCutoff()
if self.mw.col.schedVer() != 1:
was_enabled = self.mw.col.sched._new_timezone_enabled()
is_enabled = f.new_timezone.isChecked()
if was_enabled != is_enabled:
if is_enabled:
self.mw.col.sched.set_creation_offset()
else:
self.mw.col.sched.clear_creation_offset()
self._updateSchedVer(f.newSched.isChecked()) self._updateSchedVer(f.newSched.isChecked())
d.setMod() d.setMod()

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>422</width> <width>422</width>
<height>611</height> <height>636</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -136,6 +136,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="new_timezone">
<property name="text">
<string notr="true">New timezone handling (not yet supported by AnkiDroid)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QComboBox" name="useCurrent"> <widget class="QComboBox" name="useCurrent">
<item> <item>
@ -559,6 +566,7 @@
<tabstop>nightMode</tabstop> <tabstop>nightMode</tabstop>
<tabstop>dayLearnFirst</tabstop> <tabstop>dayLearnFirst</tabstop>
<tabstop>newSched</tabstop> <tabstop>newSched</tabstop>
<tabstop>new_timezone</tabstop>
<tabstop>useCurrent</tabstop> <tabstop>useCurrent</tabstop>
<tabstop>newSpread</tabstop> <tabstop>newSpread</tabstop>
<tabstop>uiScale</tabstop> <tabstop>uiScale</tabstop>
@ -571,6 +579,7 @@
<tabstop>syncOnProgramOpen</tabstop> <tabstop>syncOnProgramOpen</tabstop>
<tabstop>fullSync</tabstop> <tabstop>fullSync</tabstop>
<tabstop>syncDeauth</tabstop> <tabstop>syncDeauth</tabstop>
<tabstop>media_log</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections> <connections>