Compare commits
No commits in common. "issue_19" and "main" have entirely different histories.
|
@ -70,8 +70,14 @@ class SearchView(InventaryMixin):
|
|||
return self.search_hids(query, offset, limit)
|
||||
|
||||
devices = []
|
||||
dev_id = []
|
||||
|
||||
for x in matches:
|
||||
devices.append(self.get_annotations(x))
|
||||
# devices.append(self.get_annotations(x))
|
||||
dev = self.get_annotations(x)
|
||||
if dev.id not in dev_id:
|
||||
devices.append(dev)
|
||||
dev_id.append(dev.id)
|
||||
|
||||
count = matches.size()
|
||||
# TODO fix of pagination, the count is not correct
|
||||
|
|
|
@ -49,10 +49,8 @@ class Build:
|
|||
self.create_annotations()
|
||||
|
||||
def index(self):
|
||||
timestamp = self.json['timestamp']
|
||||
snap = json.dumps(self.json)
|
||||
|
||||
index(self.user.institution, self.get_hid(self.json) , self.uuid, timestamp, snap)
|
||||
index(self.user.institution, self.uuid, snap)
|
||||
|
||||
def generate_chids(self):
|
||||
self.algorithms = {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import xapian
|
||||
from datetime import datetime
|
||||
|
||||
# database = xapian.WritableDatabase("db", xapian.DB_CREATE_OR_OPEN)
|
||||
|
||||
|
@ -29,17 +28,11 @@ def search(institution, qs, offset=0, limit=10):
|
|||
)
|
||||
enquire = xapian.Enquire(database)
|
||||
enquire.set_query(final_query)
|
||||
|
||||
enquire.set_sort_by_value_then_relevance(0, True)
|
||||
|
||||
#colapse key is device_id
|
||||
enquire.set_collapse_key(1)
|
||||
|
||||
matches = enquire.get_mset(offset, limit)
|
||||
return matches
|
||||
|
||||
|
||||
def index(institution, device_id, uuid, timestamp, snap):
|
||||
def index(institution, uuid, snap):
|
||||
uuid = 'uuid:"{}"'.format(uuid)
|
||||
matches = search(institution, uuid, limit=1)
|
||||
if matches and matches.size() > 0:
|
||||
|
@ -57,18 +50,6 @@ def index(institution, device_id, uuid, timestamp, snap):
|
|||
indexer.index_text(snap)
|
||||
indexer.index_text(uuid, 10, "uuid")
|
||||
# indexer.index_text(snap, 1, "snapshot")
|
||||
|
||||
# store device_id, uuid and timestamp
|
||||
doc.add_value(1, device_id)
|
||||
doc.add_value(2, str(uuid))
|
||||
|
||||
try:
|
||||
timestamp_dt = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S.%f')
|
||||
timestamp_unix = timestamp_dt.timestamp()
|
||||
doc.add_value(0, xapian.sortable_serialise(timestamp_unix))
|
||||
except ValueError as e:
|
||||
print(f"Error parsing timestamp: {e}")
|
||||
|
||||
institution_term = "U{}".format(institution.id)
|
||||
doc.add_term(institution_term)
|
||||
|
||||
|
|
|
@ -101,8 +101,6 @@ def create_index(doc, user):
|
|||
if not doc or not doc.get('uuid'):
|
||||
return []
|
||||
|
||||
_timestamp = doc['endTime']
|
||||
_uuid = doc['uuid']
|
||||
_device_id = doc['CUSTOMER_ID']
|
||||
ev = json.dumps(doc)
|
||||
index(user.institution, _device_id, _uuid, _timestamp, ev)
|
||||
index(user.institution, _uuid, ev)
|
||||
|
|
Loading…
Reference in New Issue