Fix incorrect rate query
This commit is contained in:
parent
d6ca5e2922
commit
04358a5506
|
@ -7,7 +7,7 @@ from typing import Dict, List, Set
|
|||
|
||||
from boltons import urlutils
|
||||
from citext import CIText
|
||||
from ereuse_utils.naming import Naming
|
||||
from ereuse_utils.naming import Naming, HID_CONVERSION_DOC
|
||||
from more_itertools import unique_everseen
|
||||
from sqlalchemy import BigInteger, Boolean, Column, Enum as DBEnum, Float, ForeignKey, Integer, \
|
||||
Sequence, SmallInteger, Unicode, inspect, text
|
||||
|
@ -57,11 +57,7 @@ class Device(Thing):
|
|||
from Devicehub using literal identifiers from the device,
|
||||
so it can re-generated *offline*.
|
||||
|
||||
The HID is the result of joining the type of device, S/N,
|
||||
manufacturer name, and model. Devices that do not have one
|
||||
of these fields cannot generate HID, thus not guaranteeing
|
||||
global uniqueness.
|
||||
"""
|
||||
""" + HID_CONVERSION_DOC
|
||||
model = Column(Unicode(), check_lower('model'))
|
||||
model.comment = """The model or brand of the device in lower case.
|
||||
|
||||
|
|
|
@ -51,7 +51,10 @@ class Filters(query.Query):
|
|||
model = query.ILike(Device.model)
|
||||
manufacturer = query.ILike(Device.manufacturer)
|
||||
serialNumber = query.ILike(Device.serial_number)
|
||||
rating = query.Join(Device.id == events.Rate.device_id, RateQ)
|
||||
# todo test query for rating (and possibly other filters)
|
||||
rating = query.Join((Device.id == events.EventWithOneDevice.device_id)
|
||||
& (events.EventWithOneDevice.id == events.Rate.id),
|
||||
RateQ)
|
||||
tag = query.Join(Device.id == Tag.device_id, TagQ)
|
||||
# todo This part of the query is really slow
|
||||
# And forces usage of distinct, as it returns many rows
|
||||
|
|
|
@ -5,7 +5,7 @@ click==6.7
|
|||
click-spinner==0.1.8
|
||||
colorama==0.3.9
|
||||
colour==0.1.5
|
||||
ereuse-utils[naming, test, session, cli]==0.4.0b19
|
||||
ereuse-utils[naming, test, session, cli]==0.4.0b20
|
||||
Flask==1.0.2
|
||||
Flask-Cors==3.0.6
|
||||
Flask-SQLAlchemy==2.3.2
|
||||
|
|
Reference in a new issue