simplify token in search

This commit is contained in:
Cayo Puigdefabregas 2020-12-17 11:35:55 +01:00
parent 5241c73a98
commit 36cd61c0bd

View file

@ -112,18 +112,6 @@ class DeviceSearch(db.Model):
if isinstance(device, Computer):
# Aggregate the values of all the components of pc
Comp = aliased(Component)
if device.chassis:
tokens.extend((
(db.func.string_agg(db.cast(Comp.id, db.TEXT), ' '), search.Weight.D),
(db.func.string_agg(Comp.model, ' '), search.Weight.C),
(db.func.string_agg(Comp.manufacturer, ' '), search.Weight.D),
(db.func.string_agg(Comp.serial_number, ' '), search.Weight.B),
(db.func.string_agg(Comp.type, ' '), search.Weight.B),
('Computer', search.Weight.C),
('PC', search.Weight.C),
(inflection.humanize(device.chassis.name), search.Weight.B),
))
else:
tokens.extend((
(db.func.string_agg(db.cast(Comp.id, db.TEXT), ' '), search.Weight.D),
(db.func.string_agg(Comp.model, ' '), search.Weight.C),