mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
no tag searching, add index to db.py
This commit is contained in:
parent
9b224263a9
commit
91114a72c5
2 changed files with 9 additions and 3 deletions
|
@ -25,7 +25,8 @@ except ImportError:
|
||||||
sqlite.enable_shared_cache(True)
|
sqlite.enable_shared_cache(True)
|
||||||
|
|
||||||
from sqlalchemy import (Table, Integer, Float, Column, MetaData,
|
from sqlalchemy import (Table, Integer, Float, Column, MetaData,
|
||||||
ForeignKey, Boolean, String, Date, UniqueConstraint)
|
ForeignKey, Boolean, String, Date,
|
||||||
|
UniqueConstraint, Index)
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import mapper, sessionmaker, relation, backref, \
|
from sqlalchemy.orm import mapper, sessionmaker, relation, backref, \
|
||||||
object_session as _object_session
|
object_session as _object_session
|
||||||
|
@ -48,8 +49,7 @@ def newWarn(*args, **kwargs):
|
||||||
oldWarn(*args, **kwargs)
|
oldWarn(*args, **kwargs)
|
||||||
util.warn = newWarn
|
util.warn = newWarn
|
||||||
|
|
||||||
|
# shared metadata
|
||||||
|
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
|
|
||||||
# this class assumes the provided session is called with transactional=False
|
# this class assumes the provided session is called with transactional=False
|
||||||
|
|
|
@ -1188,6 +1188,12 @@ from cards, facts, models where
|
||||||
cards.factId == facts.id and facts.modelId == models.id
|
cards.factId == facts.id and facts.modelId == models.id
|
||||||
%s""" % where)
|
%s""" % where)
|
||||||
|
|
||||||
|
def cardsWithNoTags(self):
|
||||||
|
return self.s.column0("""
|
||||||
|
select cards.id from cards, facts where
|
||||||
|
cards.tags = "" and facts.tags = ""
|
||||||
|
and cards.factId = facts.id""")
|
||||||
|
|
||||||
def allTags(self):
|
def allTags(self):
|
||||||
"Return a hash listing tags in model, fact and cards."
|
"Return a hash listing tags in model, fact and cards."
|
||||||
return list(set(parseTags(",".join([x[1] for x in self.tagsList()]))))
|
return list(set(parseTags(",".join([x[1] for x in self.tagsList()]))))
|
||||||
|
|
Loading…
Reference in a new issue