Skip to content

Commit

Permalink
use doubles for percentage, combine linear timing function, 400ms tra…
Browse files Browse the repository at this point in the history
…nsition and status update 3 times a second for smooth load bar
  • Loading branch information
patrickbr committed Oct 6, 2023
1 parent 83822b9 commit 7ca1671
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/qlever-petrimaps/GeomCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ double GeomCache::getLoadStatusPercent(bool total) {

if (!total) {
return std::atomic<size_t>(_curRow) / static_cast<double>(_totalSize) *
100.0f;
100.0;
}

float parsePercent = 95.0f;
float parseIdsPercent = 5.0f;
float totalPercent = 0.0f;
double parsePercent = 95.0;
double parseIdsPercent = 5.0;
double totalPercent = 0.0;
switch (_loadStatusStage) {
case _LoadStatusStages::Parse:
totalPercent = std::atomic<size_t>(_curRow) /
Expand Down
7 changes: 4 additions & 3 deletions src/qlever-petrimaps/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include <png.h>

#include <algorithm>
#include <chrono>
#include <codecvt>
#include <csignal>
#include <locale>
#include <memory>
#include <algorithm>
#include <random>
#include <set>
#include <unordered_set>
Expand Down Expand Up @@ -1128,7 +1128,8 @@ util::http::Answer Server::handleLoadStatusReq(const Params& pars) const {
int loadStatusStage = cache->getLoadStatusStage();

std::stringstream json;
json << "{\"percent\": " << loadStatusPercent << ", \"stage\": " << loadStatusStage << "}";
json << "{\"percent\": " << loadStatusPercent
<< ", \"stage\": " << loadStatusStage << "}";
util::http::Answer ans = util::http::Answer("200 OK", json.str());

return ans;
Expand Down Expand Up @@ -1182,7 +1183,7 @@ void Server::createCache(const std::string& backend) const {

// _____________________________________________________________________________
void Server::loadCache(const std::string& backend) const {
//std::shared_ptr<Requestor> reqor;
// std::shared_ptr<Requestor> reqor;
std::shared_ptr<GeomCache> cache = _caches[backend];

try {
Expand Down
2 changes: 1 addition & 1 deletion web/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ async function fetchLoadStatus() {
}

fetchResults();
fetchLoadStatusInterval(1000);
fetchLoadStatusInterval(333);

document.getElementById("ex-geojson").onclick = function() {
if (!sessionId) return;
Expand Down
6 changes: 3 additions & 3 deletions web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ h1, #msg-inner {

#load-status {
display: grid;

width: 100%;
background-color: white;

Expand All @@ -715,7 +714,8 @@ h1, #msg-inner {
width: 0%;
height: 30px;
background-color: black;
transition: width 500ms;
transition: width 400ms;
transition-timing-function: linear;
}

#load-percent {
Expand Down Expand Up @@ -775,4 +775,4 @@ h1, #msg-inner {

.export-link {
font-size: 80%;
}
}

0 comments on commit 7ca1671

Please sign in to comment.