-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webui: separate search results by job ids #170
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,20 +1,21 @@ | ||||||||||
import {Meteor} from "meteor/meteor"; | ||||||||||
|
||||||||||
import {SEARCH_SERVER_STATE_COLLECTION_NAME} from "../publications"; | ||||||||||
import {SEARCH_SERVER_STATE_COLLECTION_NAME, SearchResultsMetadataCollection} from "../publications"; | ||||||||||
import {currentServerStateList} from "./query_handler_mediator"; | ||||||||||
|
||||||||||
const MyCollections = {}; | ||||||||||
const createCollectionsIfNotExist = (sessionId) => { | ||||||||||
if (!(sessionId in MyCollections)) { | ||||||||||
MyCollections[sessionId] = { | ||||||||||
[Meteor.settings.public.SearchResultsCollectionName]: null, | ||||||||||
[Meteor.settings.public.SearchResultsMetadataCollectionName]: null, | ||||||||||
}; | ||||||||||
MyCollections[sessionId][Meteor.settings.public.SearchResultsCollectionName] = | ||||||||||
new Mongo.Collection(`${Meteor.settings.public.SearchResultsCollectionName}_${sessionId}`); | ||||||||||
MyCollections[sessionId][Meteor.settings.public.SearchResultsMetadataCollectionName] = | ||||||||||
new Mongo.Collection(`${Meteor.settings.public.SearchResultsMetadataCollectionName}_${sessionId}`); | ||||||||||
const createCollectionsIfNotExist = (sessionId, jobID) => { | ||||||||||
const collectionName = `${Meteor.settings.public.SearchResultsCollectionName}_${jobID}`; | ||||||||||
|
||||||||||
if ((MyCollections[sessionId] !== undefined) && | ||||||||||
(MyCollections[sessionId][Meteor.settings.public.SearchResultsCollectionName]._name === collectionName)) { | ||||||||||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
return; | ||||||||||
} | ||||||||||
MyCollections[sessionId] = { | ||||||||||
[Meteor.settings.public.SearchResultsCollectionName]: null, | ||||||||||
}; | ||||||||||
MyCollections[sessionId][Meteor.settings.public.SearchResultsCollectionName] = | ||||||||||
new Mongo.Collection(collectionName); | ||||||||||
} | ||||||||||
|
||||||||||
// TODO: revisit: there is no need to isolate this collection per user/session because it is already done so by meteor? | ||||||||||
|
@@ -36,15 +37,17 @@ Meteor.publish(Meteor.settings.public.SearchResultsMetadataCollectionName, funct | |||||||||
let findOptions = { | ||||||||||
disableOplog: true, pollingIntervalMs: 250 | ||||||||||
}; | ||||||||||
createCollectionsIfNotExist(this.userId); | ||||||||||
return MyCollections[this.userId][Meteor.settings.public.SearchResultsMetadataCollectionName].find({}, findOptions); | ||||||||||
return SearchResultsMetadataCollection.find({}, findOptions); | ||||||||||
}); | ||||||||||
|
||||||||||
Meteor.publish(Meteor.settings.public.SearchResultsCollectionName, function search_results_publication({ | ||||||||||
visibleTimeRange, | ||||||||||
fieldToSortBy, | ||||||||||
visibleSearchResultsLimit | ||||||||||
}) { | ||||||||||
if ((!currentServerStateList[this.userId]) || !(currentServerStateList[this.userId].jobID)) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We should make explicit comparison rather than using |
||||||||||
return [] | ||||||||||
} | ||||||||||
let selector = {}; | ||||||||||
if (null !== visibleTimeRange.begin && null !== visibleTimeRange.end) { | ||||||||||
selector["timestamp"] = { | ||||||||||
|
@@ -62,6 +65,6 @@ Meteor.publish(Meteor.settings.public.SearchResultsCollectionName, function sear | |||||||||
findOptions["sort"] = sort; | ||||||||||
} | ||||||||||
|
||||||||||
createCollectionsIfNotExist(this.userId); | ||||||||||
createCollectionsIfNotExist(this.userId, currentServerStateList[this.userId].jobID); | ||||||||||
return MyCollections[this.userId][Meteor.settings.public.SearchResultsCollectionName].find(selector, findOptions); | ||||||||||
}); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -88,6 +88,7 @@ class WebUiQueryHandlerWebsocket { | |||||
case ServerMessageType.QUERY_STARTED: | ||||||
if (SearchState.WAITING_FOR_QUERY_TO_START === currentServerStateList[this.__sessionId].state) { | ||||||
currentServerStateList[this.__sessionId].state = SearchState.QUERY_IN_PROGRESS; | ||||||
currentServerStateList[this.__sessionId].jobID = message['value']['jobID'] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else { | ||||||
// Should not be possible, so disconnect | ||||||
console.error("Got QUERY_STARTED while in impossible state."); | ||||||
|
@@ -118,7 +119,7 @@ class WebUiQueryHandlerWebsocket { | |||||
|
||||||
export function initCurrentServerState(sessionId) { | ||||||
if (currentServerStateList[sessionId] === undefined) { | ||||||
currentServerStateList[sessionId] = {state: null, errorMessage: ""}; | ||||||
currentServerStateList[sessionId] = {state: null, errorMessage: "", jobID: null}; | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this inline comment to the function body and mark it as
TODO
?