mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Lookup index now contains default form names.
This commit is contained in:
parent
907a24f863
commit
add2111205
1 changed files with 23 additions and 11 deletions
|
@ -148,22 +148,34 @@ class PokedexLookup(object):
|
||||||
for row in q.yield_per(5):
|
for row in q.yield_per(5):
|
||||||
# Need to give forme_name a dummy value because I can't
|
# Need to give forme_name a dummy value because I can't
|
||||||
# search for explicitly empty fields. Boo.
|
# search for explicitly empty fields. Boo.
|
||||||
row_key = dict(table=unicode(cls.__tablename__),
|
row_keys = [
|
||||||
|
dict(table=unicode(cls.__tablename__),
|
||||||
row_id=unicode(row.id),
|
row_id=unicode(row.id),
|
||||||
forme_name=u'__empty__')
|
forme_name=u'__empty__')
|
||||||
|
]
|
||||||
|
|
||||||
|
# If this is a form, mark it as such
|
||||||
|
# XXX foreign form names...?
|
||||||
|
if getattr(row, 'forme_name', None):
|
||||||
|
# ...but if it's also the *default* form, index the name
|
||||||
|
# bare too
|
||||||
|
if not getattr(row, 'forme_base_pokemon_id', None):
|
||||||
|
new_key = row_keys[0].copy()
|
||||||
|
row_keys.append(new_key)
|
||||||
|
|
||||||
|
row_keys[0]['forme_name'] = row.forme_name
|
||||||
|
|
||||||
def add(name, language, iso3166, score):
|
def add(name, language, iso3166, score):
|
||||||
normalized_name = self.normalize_name(name)
|
normalized_name = self.normalize_name(name)
|
||||||
|
for row_key in row_keys:
|
||||||
writer.add_document(
|
writer.add_document(
|
||||||
name=normalized_name, display_name=name,
|
name=normalized_name, display_name=name,
|
||||||
language=language, iso3166=iso3166,
|
language=language, iso3166=iso3166,
|
||||||
**row_key
|
**row_key
|
||||||
)
|
)
|
||||||
|
|
||||||
speller_entries.append((normalized_name, score))
|
speller_entries.append((normalized_name, score))
|
||||||
|
|
||||||
# If this is a form, mark it as such
|
|
||||||
if getattr(row, 'forme_base_pokemon_id', None):
|
|
||||||
row_key['forme_name'] = row.forme_name
|
|
||||||
|
|
||||||
name = row.name
|
name = row.name
|
||||||
add(name, None, u'us', 1)
|
add(name, None, u'us', 1)
|
||||||
|
|
Loading…
Reference in a new issue