Remove unused backend methods & formatting

This commit is contained in:
abdo 2021-01-09 17:48:34 +03:00
parent 5919d9273f
commit 0b5bb711a1
2 changed files with 137 additions and 159 deletions

View File

@ -66,167 +66,162 @@ message DeckConfigID {
int64 dcid = 1; int64 dcid = 1;
} }
message TagID {
int64 tid = 1;
}
// New style RPC definitions // New style RPC definitions
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
service BackendService { service BackendService {
rpc LatestProgress (Empty) returns (Progress); rpc LatestProgress(Empty) returns (Progress);
rpc SetWantsAbort (Empty) returns (Empty); rpc SetWantsAbort(Empty) returns (Empty);
// card rendering // card rendering
rpc ExtractAVTags (ExtractAVTagsIn) returns (ExtractAVTagsOut); rpc ExtractAVTags(ExtractAVTagsIn) returns (ExtractAVTagsOut);
rpc ExtractLatex (ExtractLatexIn) returns (ExtractLatexOut); rpc ExtractLatex(ExtractLatexIn) returns (ExtractLatexOut);
rpc GetEmptyCards (Empty) returns (EmptyCardsReport); rpc GetEmptyCards(Empty) returns (EmptyCardsReport);
rpc RenderExistingCard (RenderExistingCardIn) returns (RenderCardOut); rpc RenderExistingCard(RenderExistingCardIn) returns (RenderCardOut);
rpc RenderUncommittedCard (RenderUncommittedCardIn) returns (RenderCardOut); rpc RenderUncommittedCard(RenderUncommittedCardIn) returns (RenderCardOut);
rpc StripAVTags (String) returns (String); rpc StripAVTags(String) returns (String);
// searching // searching
rpc NormalizeSearch (String) returns (String); rpc NormalizeSearch(String) returns (String);
rpc SearchCards (SearchCardsIn) returns (SearchCardsOut); rpc SearchCards(SearchCardsIn) returns (SearchCardsOut);
rpc SearchNotes (SearchNotesIn) returns (SearchNotesOut); rpc SearchNotes(SearchNotesIn) returns (SearchNotesOut);
rpc NegateSearch (String) returns (String); rpc NegateSearch(String) returns (String);
rpc ConcatenateSearches (ConcatenateSearchesIn) returns (String); rpc ConcatenateSearches(ConcatenateSearchesIn) returns (String);
rpc ReplaceSearchTerm (ReplaceSearchTermIn) returns (String); rpc ReplaceSearchTerm(ReplaceSearchTermIn) returns (String);
rpc FindAndReplace (FindAndReplaceIn) returns (UInt32); rpc FindAndReplace(FindAndReplaceIn) returns (UInt32);
// scheduling // scheduling
rpc LocalMinutesWest (Int64) returns (Int32); rpc LocalMinutesWest(Int64) returns (Int32);
rpc SetLocalMinutesWest (Int32) returns (Empty); rpc SetLocalMinutesWest(Int32) returns (Empty);
rpc SchedTimingToday (Empty) returns (SchedTimingTodayOut); rpc SchedTimingToday(Empty) returns (SchedTimingTodayOut);
rpc StudiedToday (Empty) returns (String); rpc StudiedToday(Empty) returns (String);
rpc StudiedTodayMessage (StudiedTodayMessageIn) returns (String); rpc StudiedTodayMessage(StudiedTodayMessageIn) returns (String);
rpc UpdateStats (UpdateStatsIn) returns (Empty); rpc UpdateStats(UpdateStatsIn) returns (Empty);
rpc ExtendLimits (ExtendLimitsIn) returns (Empty); rpc ExtendLimits(ExtendLimitsIn) returns (Empty);
rpc CountsForDeckToday (DeckID) returns (CountsForDeckTodayOut); rpc CountsForDeckToday(DeckID) returns (CountsForDeckTodayOut);
rpc CongratsInfo (Empty) returns (CongratsInfoOut); rpc CongratsInfo(Empty) returns (CongratsInfoOut);
rpc RestoreBuriedAndSuspendedCards (CardIDs) returns (Empty); rpc RestoreBuriedAndSuspendedCards(CardIDs) returns (Empty);
rpc UnburyCardsInCurrentDeck (UnburyCardsInCurrentDeckIn) returns (Empty); rpc UnburyCardsInCurrentDeck(UnburyCardsInCurrentDeckIn) returns (Empty);
rpc BuryOrSuspendCards (BuryOrSuspendCardsIn) returns (Empty); rpc BuryOrSuspendCards(BuryOrSuspendCardsIn) returns (Empty);
rpc EmptyFilteredDeck (DeckID) returns (Empty); rpc EmptyFilteredDeck(DeckID) returns (Empty);
rpc RebuildFilteredDeck (DeckID) returns (UInt32); rpc RebuildFilteredDeck(DeckID) returns (UInt32);
rpc ScheduleCardsAsReviews (ScheduleCardsAsReviewsIn) returns (Empty); rpc ScheduleCardsAsReviews(ScheduleCardsAsReviewsIn) returns (Empty);
rpc ScheduleCardsAsNew (ScheduleCardsAsNewIn) returns (Empty); rpc ScheduleCardsAsNew(ScheduleCardsAsNewIn) returns (Empty);
rpc SortCards (SortCardsIn) returns (Empty); rpc SortCards(SortCardsIn) returns (Empty);
rpc SortDeck (SortDeckIn) returns (Empty); rpc SortDeck(SortDeckIn) returns (Empty);
// stats // stats
rpc CardStats (CardID) returns (String); rpc CardStats(CardID) returns (String);
rpc Graphs(GraphsIn) returns (GraphsOut); rpc Graphs(GraphsIn) returns (GraphsOut);
// media // media
rpc CheckMedia (Empty) returns (CheckMediaOut); rpc CheckMedia(Empty) returns (CheckMediaOut);
rpc TrashMediaFiles (TrashMediaFilesIn) returns (Empty); rpc TrashMediaFiles(TrashMediaFilesIn) returns (Empty);
rpc AddMediaFile (AddMediaFileIn) returns (String); rpc AddMediaFile(AddMediaFileIn) returns (String);
rpc EmptyTrash (Empty) returns (Empty); rpc EmptyTrash(Empty) returns (Empty);
rpc RestoreTrash (Empty) returns (Empty); rpc RestoreTrash(Empty) returns (Empty);
// decks // decks
rpc AddOrUpdateDeckLegacy (AddOrUpdateDeckLegacyIn) returns (DeckID); rpc AddOrUpdateDeckLegacy(AddOrUpdateDeckLegacyIn) returns (DeckID);
rpc DeckTree (DeckTreeIn) returns (DeckTreeNode); rpc DeckTree(DeckTreeIn) returns (DeckTreeNode);
rpc DeckTreeLegacy (Empty) returns (Json); rpc DeckTreeLegacy(Empty) returns (Json);
rpc GetAllDecksLegacy (Empty) returns (Json); rpc GetAllDecksLegacy(Empty) returns (Json);
rpc GetDeckIDByName (String) returns (DeckID); rpc GetDeckIDByName(String) returns (DeckID);
rpc GetDeckLegacy (DeckID) returns (Json); rpc GetDeckLegacy(DeckID) returns (Json);
rpc GetDeckNames (GetDeckNamesIn) returns (DeckNames); rpc GetDeckNames(GetDeckNamesIn) returns (DeckNames);
rpc NewDeckLegacy (Bool) returns (Json); rpc NewDeckLegacy(Bool) returns (Json);
rpc RemoveDeck (DeckID) returns (Empty); rpc RemoveDeck(DeckID) returns (Empty);
// deck config // deck config
rpc AddOrUpdateDeckConfigLegacy (AddOrUpdateDeckConfigLegacyIn) returns (DeckConfigID); rpc AddOrUpdateDeckConfigLegacy(AddOrUpdateDeckConfigLegacyIn)
rpc AllDeckConfigLegacy (Empty) returns (Json); returns (DeckConfigID);
rpc GetDeckConfigLegacy (DeckConfigID) returns (Json); rpc AllDeckConfigLegacy(Empty) returns (Json);
rpc NewDeckConfigLegacy (Empty) returns (Json); rpc GetDeckConfigLegacy(DeckConfigID) returns (Json);
rpc RemoveDeckConfig (DeckConfigID) returns (Empty); rpc NewDeckConfigLegacy(Empty) returns (Json);
rpc RemoveDeckConfig(DeckConfigID) returns (Empty);
// cards // cards
rpc GetCard (CardID) returns (Card); rpc GetCard(CardID) returns (Card);
rpc UpdateCard (Card) returns (Empty); rpc UpdateCard(Card) returns (Empty);
rpc AddCard (Card) returns (CardID); rpc AddCard(Card) returns (CardID);
rpc RemoveCards (RemoveCardsIn) returns (Empty); rpc RemoveCards(RemoveCardsIn) returns (Empty);
rpc SetDeck (SetDeckIn) returns (Empty); rpc SetDeck(SetDeckIn) returns (Empty);
// notes // notes
rpc NewNote (NoteTypeID) returns (Note); rpc NewNote(NoteTypeID) returns (Note);
rpc AddNote (AddNoteIn) returns (NoteID); rpc AddNote(AddNoteIn) returns (NoteID);
rpc UpdateNote (Note) returns (Empty); rpc UpdateNote(Note) returns (Empty);
rpc GetNote (NoteID) returns (Note); rpc GetNote(NoteID) returns (Note);
rpc RemoveNotes (RemoveNotesIn) returns (Empty); rpc RemoveNotes(RemoveNotesIn) returns (Empty);
rpc AddNoteTags (AddNoteTagsIn) returns (UInt32); rpc AddNoteTags(AddNoteTagsIn) returns (UInt32);
rpc UpdateNoteTags (UpdateNoteTagsIn) returns (UInt32); rpc UpdateNoteTags(UpdateNoteTagsIn) returns (UInt32);
rpc GetNoteTags(GetNoteTagsIn) returns (GetNoteTagsOut); rpc GetNoteTags(GetNoteTagsIn) returns (GetNoteTagsOut);
rpc ClozeNumbersInNote (Note) returns (ClozeNumbersInNoteOut); rpc ClozeNumbersInNote(Note) returns (ClozeNumbersInNoteOut);
rpc AfterNoteUpdates (AfterNoteUpdatesIn) returns (Empty); rpc AfterNoteUpdates(AfterNoteUpdatesIn) returns (Empty);
rpc FieldNamesForNotes (FieldNamesForNotesIn) returns (FieldNamesForNotesOut); rpc FieldNamesForNotes(FieldNamesForNotesIn) returns (FieldNamesForNotesOut);
rpc NoteIsDuplicateOrEmpty (Note) returns (NoteIsDuplicateOrEmptyOut); rpc NoteIsDuplicateOrEmpty(Note) returns (NoteIsDuplicateOrEmptyOut);
rpc CardsOfNote (NoteID) returns (CardIDs); rpc CardsOfNote(NoteID) returns (CardIDs);
// note types // note types
rpc AddOrUpdateNotetype (AddOrUpdateNotetypeIn) returns (NoteTypeID); rpc AddOrUpdateNotetype(AddOrUpdateNotetypeIn) returns (NoteTypeID);
rpc GetStockNotetypeLegacy (GetStockNotetypeIn) returns (Json); rpc GetStockNotetypeLegacy(GetStockNotetypeIn) returns (Json);
rpc GetNotetypeLegacy (NoteTypeID) returns (Json); rpc GetNotetypeLegacy(NoteTypeID) returns (Json);
rpc GetNotetypeNames (Empty) returns (NoteTypeNames); rpc GetNotetypeNames(Empty) returns (NoteTypeNames);
rpc GetNotetypeNamesAndCounts (Empty) returns (NoteTypeUseCounts); rpc GetNotetypeNamesAndCounts(Empty) returns (NoteTypeUseCounts);
rpc GetNotetypeIDByName (String) returns (NoteTypeID); rpc GetNotetypeIDByName(String) returns (NoteTypeID);
rpc RemoveNotetype (NoteTypeID) returns (Empty); rpc RemoveNotetype(NoteTypeID) returns (Empty);
// collection // collection
rpc OpenCollection (OpenCollectionIn) returns (Empty); rpc OpenCollection(OpenCollectionIn) returns (Empty);
rpc CloseCollection (CloseCollectionIn) returns (Empty); rpc CloseCollection(CloseCollectionIn) returns (Empty);
rpc CheckDatabase (Empty) returns (CheckDatabaseOut); rpc CheckDatabase(Empty) returns (CheckDatabaseOut);
// sync // sync
rpc SyncMedia (SyncAuth) returns (Empty); rpc SyncMedia(SyncAuth) returns (Empty);
rpc AbortSync (Empty) returns (Empty); rpc AbortSync(Empty) returns (Empty);
rpc AbortMediaSync (Empty) returns (Empty); rpc AbortMediaSync(Empty) returns (Empty);
rpc BeforeUpload (Empty) returns (Empty); rpc BeforeUpload(Empty) returns (Empty);
rpc SyncLogin (SyncLoginIn) returns (SyncAuth); rpc SyncLogin(SyncLoginIn) returns (SyncAuth);
rpc SyncStatus (SyncAuth) returns (SyncStatusOut); rpc SyncStatus(SyncAuth) returns (SyncStatusOut);
rpc SyncCollection (SyncAuth) returns (SyncCollectionOut); rpc SyncCollection(SyncAuth) returns (SyncCollectionOut);
rpc FullUpload (SyncAuth) returns (Empty); rpc FullUpload(SyncAuth) returns (Empty);
rpc FullDownload (SyncAuth) returns (Empty); rpc FullDownload(SyncAuth) returns (Empty);
// translation/messages // translation/messages
rpc TranslateString (TranslateStringIn) returns (String); rpc TranslateString(TranslateStringIn) returns (String);
rpc FormatTimespan (FormatTimespanIn) returns (String); rpc FormatTimespan(FormatTimespanIn) returns (String);
rpc I18nResources (Empty) returns (Json); rpc I18nResources(Empty) returns (Json);
// tags // tags
rpc RegisterTags (RegisterTagsIn) returns (Bool); rpc RegisterTags(RegisterTagsIn) returns (Bool);
rpc AllTags (Empty) returns (AllTagsOut); rpc AllTags(Empty) returns (AllTagsOut);
rpc GetTag (String) returns (Tag); rpc SetTagCollapsed(SetTagCollapsedIn) returns (Bool);
rpc UpdateTag (Tag) returns (Bool); rpc ClearTag(String) returns (Bool);
rpc SetTagCollapsed (SetTagCollapsedIn) returns (Bool); rpc TagTree(Empty) returns (TagTreeNode);
rpc ClearTag (String) returns (Bool);
rpc TagTree (Empty) returns (TagTreeNode);
// config/preferences // config/preferences
rpc GetConfigJson (String) returns (Json); rpc GetConfigJson(String) returns (Json);
rpc SetConfigJson (SetConfigJsonIn) returns (Empty); rpc SetConfigJson(SetConfigJsonIn) returns (Empty);
rpc RemoveConfig (String) returns (Empty); rpc RemoveConfig(String) returns (Empty);
rpc SetAllConfig (Json) returns (Empty); rpc SetAllConfig(Json) returns (Empty);
rpc GetAllConfig (Empty) returns (Json); rpc GetAllConfig(Empty) returns (Json);
rpc GetPreferences (Empty) returns (Preferences); rpc GetPreferences(Empty) returns (Preferences);
rpc SetPreferences (Preferences) returns (Empty); rpc SetPreferences(Preferences) returns (Empty);
} }
// Protobuf stored in .anki2 files // Protobuf stored in .anki2 files
@ -794,23 +789,23 @@ message RegisterTagsIn {
} }
message AllTagsOut { message AllTagsOut {
repeated Tag tags = 1; repeated Tag tags = 1;
} }
message SetTagCollapsedIn { message SetTagCollapsedIn {
string name = 1; string name = 1;
bool collapsed = 2; bool collapsed = 2;
} }
message TagConfig { message TagConfig {
bool browser_collapsed = 1; bool browser_collapsed = 1;
} }
message Tag { message Tag {
int64 id = 1; int64 id = 1;
string name = 2; string name = 2;
sint32 usn = 3; sint32 usn = 3;
TagConfig config = 4; TagConfig config = 4;
} }
message GetChangedTagsOut { message GetChangedTagsOut {
@ -818,11 +813,11 @@ message GetChangedTagsOut {
} }
message TagTreeNode { message TagTreeNode {
int64 tag_id = 1; int64 tag_id = 1;
string name = 2; string name = 2;
repeated TagTreeNode children = 3; repeated TagTreeNode children = 3;
uint32 level = 5; uint32 level = 5;
bool collapsed = 4; bool collapsed = 4;
} }
message SetConfigJsonIn { message SetConfigJsonIn {
@ -932,11 +927,11 @@ message UpdateNoteTagsIn {
} }
message GetNoteTagsIn { message GetNoteTagsIn {
repeated int64 nids = 1; repeated int64 nids = 1;
} }
message GetNoteTagsOut { message GetNoteTagsOut {
repeated string tags = 1; repeated string tags = 1;
} }
message CheckDatabaseOut { message CheckDatabaseOut {

View File

@ -1300,23 +1300,6 @@ impl BackendService for Backend {
Ok(pb::AllTagsOut { tags }) Ok(pb::AllTagsOut { tags })
} }
fn get_tag(&self, name: pb::String) -> BackendResult<pb::Tag> {
self.with_col(|col| {
if let Some(tag) = col.storage.get_tag(name.val.as_str())? {
Ok(tag.into())
} else {
Err(AnkiError::NotFound)
}
})
}
fn update_tag(&self, tag: pb::Tag) -> BackendResult<pb::Bool> {
self.with_col(|col| {
col.update_tag(&tag.into())?;
Ok(pb::Bool { val: true })
})
}
fn set_tag_collapsed(&self, input: pb::SetTagCollapsedIn) -> BackendResult<pb::Bool> { fn set_tag_collapsed(&self, input: pb::SetTagCollapsedIn) -> BackendResult<pb::Bool> {
self.with_col(|col| { self.with_col(|col| {
let name = &input.name; let name = &input.name;