mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
embed BuiltinSortKind
This commit is contained in:
parent
5974163343
commit
260a270eb0
5 changed files with 27 additions and 33 deletions
|
@ -42,7 +42,6 @@ assert rsbridge.buildhash() == anki.buildinfo.buildhash
|
|||
# by external libraries (eg aqt) should be exported in the module that
|
||||
# refers to them, eg collection.py
|
||||
SchedTimingToday = pb.SchedTimingTodayOut
|
||||
BuiltinSortKind = pb.BuiltinSearchOrder.BuiltinSortKind
|
||||
BackendCard = pb.Card
|
||||
BackendNote = pb.Note
|
||||
Tag = pb.Tag
|
||||
|
|
|
@ -58,12 +58,14 @@ ConfigBoolKey = _pb.ConfigBool.Key # pylint: disable=no-member
|
|||
EmptyCardsReport = _pb.EmptyCardsReport
|
||||
NoteWithEmptyCards = _pb.NoteWithEmptyCards
|
||||
GraphPreferences = _pb.GraphPreferences
|
||||
BuiltinSortKind = _pb.SortOrder.Builtin.Kind # pylint: disable=no-member
|
||||
|
||||
# pylint: disable=no-member
|
||||
if TYPE_CHECKING:
|
||||
from anki.lang import FormatTimeSpanContextValue, TRValue
|
||||
|
||||
ConfigBoolKeyValue = _pb.ConfigBool.KeyValue
|
||||
BuiltinSortKindValue = _pb.SortOrder.Builtin.KindValue
|
||||
|
||||
|
||||
class Collection:
|
||||
|
@ -460,11 +462,7 @@ class Collection:
|
|||
def find_cards(
|
||||
self,
|
||||
query: str,
|
||||
order: Union[
|
||||
bool,
|
||||
str,
|
||||
_pb.BuiltinSearchOrder.BuiltinSortKindValue, # pylint: disable=no-member
|
||||
] = False,
|
||||
order: Union[bool, str, BuiltinSortKindValue] = False,
|
||||
reverse: bool = False,
|
||||
) -> Sequence[int]:
|
||||
if isinstance(order, str):
|
||||
|
@ -476,7 +474,7 @@ class Collection:
|
|||
mode = _pb.SortOrder(none=_pb.Empty())
|
||||
else:
|
||||
mode = _pb.SortOrder(
|
||||
builtin=_pb.BuiltinSearchOrder(kind=order, reverse=reverse)
|
||||
builtin=_pb.SortOrder.Builtin(kind=order, reverse=reverse)
|
||||
)
|
||||
return self.backend.search_cards(search=query, order=mode)
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# coding: utf-8
|
||||
import pytest
|
||||
|
||||
from anki._backend import BuiltinSortKind
|
||||
from anki.collection import ConfigBoolKey
|
||||
from anki.collection import BuiltinSortKind, ConfigBoolKey
|
||||
from anki.consts import *
|
||||
from tests.shared import getEmptyCol, isNearCutoff
|
||||
|
||||
|
|
|
@ -729,11 +729,30 @@ message SearchCardsOut {
|
|||
}
|
||||
|
||||
message SortOrder {
|
||||
message Builtin {
|
||||
enum Kind {
|
||||
NOTE_CREATION = 0;
|
||||
NOTE_MOD = 1;
|
||||
NOTE_FIELD = 2;
|
||||
NOTE_TAGS = 3;
|
||||
NOTE_TYPE = 4;
|
||||
CARD_MOD = 5;
|
||||
CARD_REPS = 6;
|
||||
CARD_DUE = 7;
|
||||
CARD_EASE = 8;
|
||||
CARD_LAPSES = 9;
|
||||
CARD_INTERVAL = 10;
|
||||
CARD_DECK = 11;
|
||||
CARD_TEMPLATE = 12;
|
||||
}
|
||||
Kind kind = 1;
|
||||
bool reverse = 2;
|
||||
}
|
||||
oneof value {
|
||||
Empty from_config = 1;
|
||||
Empty none = 2;
|
||||
string custom = 3;
|
||||
BuiltinSearchOrder builtin = 4;
|
||||
Builtin builtin = 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,26 +764,6 @@ message SearchNotesOut {
|
|||
repeated int64 note_ids = 2;
|
||||
}
|
||||
|
||||
message BuiltinSearchOrder {
|
||||
enum BuiltinSortKind {
|
||||
NOTE_CREATION = 0;
|
||||
NOTE_MOD = 1;
|
||||
NOTE_FIELD = 2;
|
||||
NOTE_TAGS = 3;
|
||||
NOTE_TYPE = 4;
|
||||
CARD_MOD = 5;
|
||||
CARD_REPS = 6;
|
||||
CARD_DUE = 7;
|
||||
CARD_EASE = 8;
|
||||
CARD_LAPSES = 9;
|
||||
CARD_INTERVAL = 10;
|
||||
CARD_DECK = 11;
|
||||
CARD_TEMPLATE = 12;
|
||||
}
|
||||
BuiltinSortKind kind = 1;
|
||||
bool reverse = 2;
|
||||
}
|
||||
|
||||
message SearchTerm {
|
||||
message Dupe {
|
||||
int64 notetype_id = 1;
|
||||
|
|
|
@ -6,10 +6,9 @@ use crate::{
|
|||
backend::dbproxy::db_command_bytes,
|
||||
backend_proto as pb,
|
||||
backend_proto::{
|
||||
builtin_search_order::BuiltinSortKind as SortKindProto,
|
||||
concatenate_searches_in::Separator as BoolSeparatorProto,
|
||||
sort_order::Value as SortOrderProto, AddOrUpdateDeckConfigLegacyIn, BackendResult, Empty,
|
||||
RenderedTemplateReplacement,
|
||||
sort_order::builtin::Kind as SortKindProto, sort_order::Value as SortOrderProto,
|
||||
AddOrUpdateDeckConfigLegacyIn, BackendResult, Empty, RenderedTemplateReplacement,
|
||||
},
|
||||
card::{Card, CardID},
|
||||
card::{CardQueue, CardType},
|
||||
|
|
Loading…
Reference in a new issue