Add GraphsPreferences endpoint to backend
This commit is contained in:
parent
d27167ce86
commit
665a13e378
@ -34,7 +34,7 @@ LABEL_REPEATED = 3
|
||||
|
||||
# messages we don't want to unroll in codegen
|
||||
SKIP_UNROLL_INPUT = {"TranslateString"}
|
||||
SKIP_DECODE = {"Graphs"}
|
||||
SKIP_DECODE = {"Graphs", "GraphsPreferences"}
|
||||
|
||||
|
||||
def python_type(field):
|
||||
|
@ -255,6 +255,10 @@ def graph_data() -> bytes:
|
||||
return aqt.mw.col.backend.graphs(search=args["search"], days=args["days"])
|
||||
|
||||
|
||||
def graph_preferences() -> bytes:
|
||||
return aqt.mw.col.backend.graphs_preferences()
|
||||
|
||||
|
||||
def congrats_info() -> bytes:
|
||||
info = aqt.mw.col.backend.congrats_info()
|
||||
return info.SerializeToString()
|
||||
@ -262,6 +266,7 @@ def congrats_info() -> bytes:
|
||||
|
||||
post_handlers = dict(
|
||||
graphData=graph_data,
|
||||
graphPreferences=graph_preferences,
|
||||
# pylint: disable=unnecessary-lambda
|
||||
i18nResources=lambda: aqt.mw.col.backend.i18n_resources(),
|
||||
congratsInfo=congrats_info,
|
||||
|
@ -116,6 +116,7 @@ service BackendService {
|
||||
|
||||
rpc CardStats(CardID) returns (String);
|
||||
rpc Graphs(GraphsIn) returns (GraphsOut);
|
||||
rpc GraphsPreferences(Empty) returns (GraphsPreferencesOut);
|
||||
|
||||
// media
|
||||
|
||||
@ -1099,6 +1100,18 @@ message GraphsOut {
|
||||
Weekday first_weekday = 8;
|
||||
}
|
||||
|
||||
message GraphsPreferencesOut {
|
||||
enum Weekday {
|
||||
SUNDAY = 0;
|
||||
MONDAY = 1;
|
||||
FRIDAY = 5;
|
||||
SATURDAY = 6;
|
||||
}
|
||||
Weekday calendar_first_day_of_week = 1;
|
||||
bool card_counts_separate_inactive = 2;
|
||||
|
||||
}
|
||||
|
||||
message RevlogEntry {
|
||||
enum ReviewKind {
|
||||
LEARNING = 0;
|
||||
|
@ -676,6 +676,10 @@ impl BackendService for Backend {
|
||||
self.with_col(|col| col.graph_data_for_search(&input.search, input.days))
|
||||
}
|
||||
|
||||
fn graphs_preferences(&self, _input: pb::Empty) -> BackendResult<pb::GraphsPreferencesOut> {
|
||||
self.with_col(|col| col.graphs_preferences())
|
||||
}
|
||||
|
||||
// decks
|
||||
//-----------------------------------------------
|
||||
|
||||
|
@ -45,6 +45,13 @@ impl Collection {
|
||||
first_weekday: self.get_first_weekday() as i32,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn graphs_preferences(&self) -> Result<pb::GraphsPreferencesOut> {
|
||||
Ok(pb::GraphsPreferencesOut {
|
||||
calendar_first_day_of_week: self.get_first_weekday() as i32,
|
||||
card_counts_separate_inactive: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RevlogEntry> for pb::RevlogEntry {
|
||||
|
@ -5,7 +5,7 @@
|
||||
import type { SvelteComponent } from "svelte/internal";
|
||||
import type { I18n } from "anki/i18n";
|
||||
import type pb from "anki/backend_proto";
|
||||
import { getGraphData, RevlogRange } from "./graph-helpers";
|
||||
import { getGraphData, getGraphPreferences, RevlogRange } from "./graph-helpers";
|
||||
|
||||
export let i18n: I18n;
|
||||
export let nightMode: boolean;
|
||||
|
@ -19,6 +19,12 @@ export async function getGraphData(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getGraphPreferences(): Promise<pb.BackendProto.GraphsPreferencesOut> {
|
||||
return pb.BackendProto.GraphsPreferencesOut.decode(
|
||||
await postRequest("/_anki/graphPreferences", JSON.stringify({}))
|
||||
);
|
||||
}
|
||||
|
||||
// amount of data to fetch from backend
|
||||
export enum RevlogRange {
|
||||
Year = 1,
|
||||
|
Loading…
Reference in New Issue
Block a user