Export last_interval to Python (#4365)

* Export last_interval to Python

* Add last_interval field to StatsRevlogEntry

* Implement last_interval_secs function

* Update last_interval field type in stats.proto

* Update last_interval to use last_interval_secs
This commit is contained in:
user1823 2025-09-27 11:28:41 +05:30 committed by GitHub
parent 03f3a005f4
commit d8aa244a5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -37,6 +37,8 @@ message CardStatsResponse {
uint32 ease = 5;
float taken_secs = 6;
optional cards.FsrsMemoryState memory_state = 7;
// seconds
uint32 last_interval = 8;
}
repeated StatsRevlogEntry revlog = 1;
int64 card_id = 2;

View file

@ -85,6 +85,15 @@ impl RevlogEntry {
.unwrap()
}
pub(crate) fn last_interval_secs(&self) -> u32 {
u32::try_from(if self.last_interval > 0 {
self.last_interval.saturating_mul(86_400)
} else {
self.last_interval.saturating_mul(-1)
})
.unwrap()
}
/// Returns true if this entry represents a reset operation.
/// These entries are created when a card is reset using
/// [`Collection::reschedule_cards_as_new`].

View file

@ -227,6 +227,7 @@ fn stats_revlog_entry(
ease: entry.ease_factor,
taken_secs: entry.taken_millis as f32 / 1000.,
memory_state: None,
last_interval: entry.last_interval_secs(),
}
}