mirror of
https://github.com/ankitects/anki.git
synced 2026-01-09 03:53:55 -05:00
fixed structure for ninja checks
This commit is contained in:
parent
8a8f07c3c3
commit
9ff49ce111
3 changed files with 36 additions and 32 deletions
|
|
@ -59,11 +59,8 @@ pub enum BoolKey {
|
||||||
/// This is a workaround for old clients that used ints to represent boolean
|
/// This is a workaround for old clients that used ints to represent boolean
|
||||||
/// values. For new config items, prefer using a bool directly.
|
/// values. For new config items, prefer using a bool directly.
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
struct BoolLike(
|
#[allow(dead_code)]
|
||||||
#[serde(deserialize_with = "deserialize_bool_from_anything")]
|
struct BoolLike(#[serde(deserialize_with = "deserialize_bool_from_anything")] bool);
|
||||||
#[allow(dead_code)]
|
|
||||||
bool,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
pub fn get_config_bool(&self, key: BoolKey) -> bool {
|
pub fn get_config_bool(&self, key: BoolKey) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -170,37 +170,37 @@ export function dayLabel(daysStart: number, daysEnd: number): string {
|
||||||
} else {
|
} else {
|
||||||
return tr.statisticsDaysAgoSingle({ days: -daysStart });
|
return tr.statisticsDaysAgoSingle({ days: -daysStart });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// range
|
||||||
|
if (daysStart >= 0) {
|
||||||
|
return tr.statisticsInDaysRange({
|
||||||
|
daysStart,
|
||||||
|
daysEnd: daysEnd - 1,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// range
|
// For bins that cross or end at day 0, we need special handling
|
||||||
if (daysStart >= 0) {
|
if (daysEnd > 0) {
|
||||||
return tr.statisticsInDaysRange({
|
// Bin crosses day 0: show from 0 to the oldest day (exclusive of endDay)
|
||||||
daysStart,
|
// If bin is [-5, 1), we want "0-4 days ago"
|
||||||
daysEnd: daysEnd - 1,
|
return tr.statisticsDaysAgoRange({
|
||||||
|
daysStart: 0,
|
||||||
|
daysEnd: -daysStart - 1,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// For bins that cross or end at day 0, we need special handling
|
// Bin is entirely in the past: show from newest to oldest
|
||||||
if (daysEnd > 0) {
|
// For a bin [startDay, endDay), to show consecutive ranges like "0-4", "5-9", "10-14",
|
||||||
// Bin crosses day 0: show from 0 to the oldest day (exclusive of endDay)
|
// we use endDay as the start of the range
|
||||||
// If bin is [-5, 1), we want "0-4 days ago"
|
// The bin width is daysEnd - daysStart, so daysEnd = daysStart + (width - 1)
|
||||||
return tr.statisticsDaysAgoRange({
|
// Example: bin [-10, -5) has width 5, should show "5-9 days ago"
|
||||||
daysStart: 0,
|
const binWidth = Math.abs(daysEnd - daysStart);
|
||||||
daysEnd: -daysStart - 1,
|
const daysStartAbs = Math.abs(daysEnd);
|
||||||
});
|
return tr.statisticsDaysAgoRange({
|
||||||
} else {
|
daysStart: daysStartAbs,
|
||||||
// Bin is entirely in the past: show from newest to oldest
|
daysEnd: daysStartAbs + binWidth - 1,
|
||||||
// For a bin [startDay, endDay), to show consecutive ranges like "0-4", "5-9", "10-14",
|
});
|
||||||
// we use endDay as the start of the range
|
|
||||||
// The bin width is daysEnd - daysStart, so daysEnd = daysStart + (width - 1)
|
|
||||||
// Example: bin [-10, -5) has width 5, should show "5-9 days ago"
|
|
||||||
const binWidth = Math.abs(daysEnd - daysStart);
|
|
||||||
const daysStartAbs = Math.abs(daysEnd);
|
|
||||||
return tr.statisticsDaysAgoRange({
|
|
||||||
daysStart: daysStartAbs,
|
|
||||||
daysEnd: daysStartAbs + binWidth - 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper for converting Unix timestamps to date strings. */
|
/** Helper for converting Unix timestamps to date strings. */
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,14 @@ export function renderReviews(
|
||||||
const startDay = Math.floor(d.x0!);
|
const startDay = Math.floor(d.x0!);
|
||||||
// If bin ends at 0, treat it as including day 0 (so use 1 as endDay for dayLabel)
|
// If bin ends at 0, treat it as including day 0 (so use 1 as endDay for dayLabel)
|
||||||
// For negative bins, use the bin end directly (dayLabel will handle the conversion)
|
// For negative bins, use the bin end directly (dayLabel will handle the conversion)
|
||||||
const endDay = d.x1! === 0 ? 1 : d.x1! < 0 ? d.x1! : Math.ceil(d.x1!);
|
let endDay: number;
|
||||||
|
if (d.x1! === 0) {
|
||||||
|
endDay = 1;
|
||||||
|
} else if (d.x1! < 0) {
|
||||||
|
endDay = d.x1!;
|
||||||
|
} else {
|
||||||
|
endDay = Math.ceil(d.x1!);
|
||||||
|
}
|
||||||
const day = dayLabel(startDay, endDay);
|
const day = dayLabel(startDay, endDay);
|
||||||
const totals = totalsForBin(d);
|
const totals = totalsForBin(d);
|
||||||
const dayTotal = valueLabel(sum(totals));
|
const dayTotal = valueLabel(sum(totals));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue