Skip to content

Commit

Permalink
Fixes fossasia#298 Add time analysis of each engine for the results r…
Browse files Browse the repository at this point in the history
…etrieved
  • Loading branch information
bhaveshAn committed Nov 22, 2017
1 parent 02c8247 commit 8af35cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ body {
z-index: -100000;
}

#time-analysis {
font-size: 1.2em;
margin: 0em 2em 2em 2em;
padding: -3em 0 -3em 0;
z-index: -100000;
}

#load {
position: relative;
display: none;
Expand Down
10 changes: 9 additions & 1 deletion app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ <h1><code>query-server</code></h1>
<div class="pagination-centered">
<img id="load" src="{{ url_for('static', filename='images/ripple.gif') }}">
</div>
<pre id="time-analysis" style="display:none;"><code class="language-xml"></code></pre>
<pre id="feed" style="display:none;"><code class="language-xml"></code></pre>
<br/><br/>
<div class="container">
Expand All @@ -115,7 +116,7 @@ <h1><code>query-server</code></h1>
</div>
<footer class="footer">
<div class="container">
<p class="text-muted">Want to contribute? <a href="https://gitter.im/fossasia/query-server" target="_blank"><img src="https://badges.gitter.im/gitterHQ/gitter.png" alt="gitter badge"></a> to get started.</p>
<p class="text-muted">Want to contribute? <a href="https://gitter.im/fossasia/query-server" target="_blank"><img src="https://badges.gitter.im/gitterHQ/gitter.png" alt="gitter badge"></a> to get started.</p>
<p>Nice? To get latest news about <code>query-server</code>, follow <a href="https://twitter.com/fossasia"><code>@FOSSASIA</code></a>.
Help to spread the news: <a class="btn btn-info" id="tweet" href="https://twitter.com/intent/tweet?hashtags=loklak&text=%20%23query-server%20%23fossasia&tw_p=tweetbutton"
role="button">tweet about this &raquo;</a></p>
Expand All @@ -128,12 +129,14 @@ <h1><code>query-server</code></h1>
if ($('#query').val()) {
$('#load').show();
$('#feed').hide();
$('#time-analysis').hide();
var sengine = $(this).val();
var squery = $('#query').val();
var sformat = $(' #format label.active input').val();
var count = $('#resp').val();
var urlloc = window.location.href.split(/\?|#/)[0] + "api/v1/search/" + sengine +
"?query=" + squery + "&format=" + sformat + "&num=" + count;
var startDate = new Date();
$.ajax({
url: urlloc,
type: 'GET',
Expand All @@ -144,6 +147,11 @@ <h1><code>query-server</code></h1>
response = JSON.stringify(response, null, 4);
} else
response = new XMLSerializer().serializeToString(response);
var endDate = new Date();
var seconds = (endDate.getTime() - startDate.getTime()) / 1000;
var time_analysis_string = "Following Results fetched in " + seconds + " seconds";
$('#time-analysis').show();
$('#time-analysis').text(time_analysis_string);
$('#feed').show();
$('#feed').text(response);
Prism.highlightElement($('#feed')[0]);
Expand Down

0 comments on commit 8af35cb

Please sign in to comment.