Skip to content

Commit

Permalink
Enhance documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTF committed Nov 20, 2023
1 parent 761d24d commit 8bf5e11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions backend/static/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ function appendRuntimeInformation(runtime_info, query, time, queryUpdate) {
parseInt(time["total"].toString().replace(/ms/, ""), 10);

const previousTimeStamp = request_log.get(queryUpdate.queryId)?.timeStamp || Number.MIN_VALUE;
// If newer runtime info for existing query or new query.
if (previousTimeStamp < queryUpdate.updateTimeStamp) {
request_log.set(queryUpdate.queryId, {
timeStamp: queryUpdate.updateTimeStamp,
runtime_info: runtime_info,
query: query
});
if (request_log.size > 10) {
// Note: `keys().next()` is the key that was inserted first.
request_log.delete(request_log.keys().next().value);
}
}
Expand Down
5 changes: 3 additions & 2 deletions backend/static/js/qleverUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ var predicateNames = {};
var objectNames = {};
var high_query_time_ms = 100;
var very_high_query_time_ms = 1000;
// Map guarantees to keep insertion order
var request_log = new Map();

// Generates a random query id only known to this client.
// We don't use consecutive ids to prevent clashes between
// several qlever-ui instances.
// different instances of the Qlever UI running at the same time.
function generateQueryId() {
if (window.isSecureContext) {
return crypto.randomUUID();
Expand Down Expand Up @@ -805,6 +804,8 @@ function renderRuntimeInformationToDom(entry = undefined) {

if ($('#logRequests').is(':checked')) {
const queryHistoryList = $("<ul/>", { class: "pagination" });
// Note: when we later iterate over this `Map`, we get the key-value
// pairs in the order in which the keys were first inserted.
for (const [key, value] of request_log.entries()) {
const link = $("<a/>", {
class: "page-link",
Expand Down

0 comments on commit 8bf5e11

Please sign in to comment.