mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
add get_revlogs API && fix the style of tooltipText of ReviewsGraph (#3490)
* add get_revlogs API * fix tooltipText of ReviewsGraph the style of true-retention shouldn't affect the style of tooltipText of ReviewsGraph * More verbose wording (dae)
This commit is contained in:
parent
aaf4994e6f
commit
f00211df35
6 changed files with 27 additions and 2 deletions
|
@ -12,6 +12,7 @@ import "anki/cards.proto";
|
|||
|
||||
service StatsService {
|
||||
rpc CardStats(cards.CardId) returns (CardStatsResponse);
|
||||
rpc GetReviewLogs(cards.CardId) returns (ReviewLogs);
|
||||
rpc Graphs(GraphsRequest) returns (GraphsResponse);
|
||||
rpc GetGraphPreferences(generic.Empty) returns (GraphPreferences);
|
||||
rpc SetGraphPreferences(GraphPreferences) returns (generic.Empty);
|
||||
|
@ -21,6 +22,10 @@ service StatsService {
|
|||
// backend service.
|
||||
service BackendStatsService {}
|
||||
|
||||
message ReviewLogs {
|
||||
repeated CardStatsResponse.StatsRevlogEntry entries = 1;
|
||||
}
|
||||
|
||||
message CardStatsResponse {
|
||||
message StatsRevlogEntry {
|
||||
int64 time = 1;
|
||||
|
|
|
@ -1004,6 +1004,11 @@ class Collection(DeprecatedNamesMixin):
|
|||
"""
|
||||
return self._backend.card_stats(card_id)
|
||||
|
||||
def get_review_logs(
|
||||
self, card_id: CardId
|
||||
) -> Sequence[stats_pb2.CardStatsResponse.StatsRevlogEntry]:
|
||||
return self._backend.get_review_logs(card_id)
|
||||
|
||||
def studied_today(self) -> str:
|
||||
return self._backend.studied_today()
|
||||
|
||||
|
|
|
@ -608,6 +608,7 @@ exposed_backend_list = [
|
|||
"get_change_notetype_info",
|
||||
# StatsService
|
||||
"card_stats",
|
||||
"get_review_logs",
|
||||
"graphs",
|
||||
"get_graph_preferences",
|
||||
"set_graph_preferences",
|
||||
|
|
|
@ -83,6 +83,13 @@ impl Collection {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_review_logs(&mut self, cid: CardId) -> Result<anki_proto::stats::ReviewLogs> {
|
||||
let revlogs = self.storage.get_revlog_entries_for_card(cid)?;
|
||||
Ok(anki_proto::stats::ReviewLogs {
|
||||
entries: revlogs.iter().rev().map(stats_revlog_entry).collect(),
|
||||
})
|
||||
}
|
||||
|
||||
fn due_date(&mut self, card: &Card) -> Result<Option<i64>> {
|
||||
Ok(match card.ctype {
|
||||
CardType::New => None,
|
||||
|
|
|
@ -12,6 +12,13 @@ impl crate::services::StatsService for Collection {
|
|||
self.card_stats(input.cid.into())
|
||||
}
|
||||
|
||||
fn get_review_logs(
|
||||
&mut self,
|
||||
input: anki_proto::cards::CardId,
|
||||
) -> error::Result<anki_proto::stats::ReviewLogs> {
|
||||
self.get_review_logs(input.cid.into())
|
||||
}
|
||||
|
||||
fn graphs(
|
||||
&mut self,
|
||||
input: anki_proto::stats::GraphsRequest,
|
||||
|
|
|
@ -65,10 +65,10 @@ export function renderTrueRetention(data: GraphsResponse, revlogRange: RevlogRan
|
|||
td.trl { border: 1px solid; text-align: left; }
|
||||
td.trr { border: 1px solid; text-align: right; }
|
||||
td.trc { border: 1px solid; text-align: center; }
|
||||
table { width: 100%; table-layout: fixed; }
|
||||
table.true-retention { width: 100%; table-layout: fixed; }
|
||||
colgroup col:first-child { width: 40% }
|
||||
</style>
|
||||
<table cellspacing="0" cellpadding="2">
|
||||
<table class="true-retention" cellspacing="0" cellpadding="2">
|
||||
<colgroup><col><col><col></colgroup>
|
||||
<tr>
|
||||
<td class="trl"><b>${scopeRange(scope)}</b></td>
|
||||
|
|
Loading…
Reference in a new issue