<commit_before>{% extends "base.html" %}

{% block title %}
Uploading {{owner}}/{{name}}
{% endblock %}

{% block content %}
<div class="container">
  <div class="inner_container">
    <p id="message" class="text-center">Your data is safely stored and is getting processed - it will be here soon!</p>
    <div id="status"></div>
  </div>
</div>
<script type="text/javascript" src="/static/js/spin.min.js"></script>
<script type="text/javascript">
  // The polling function
  function poll(fn, timeout, interval) {
    var endTime = Number(new Date()) + (timeout || 2000);
    interval = interval || 100;

    var checkCondition = function(resolve, reject) {
        // If the condition is met, we're done!
        fn().then(function(res) {
          if (res.state === 'SUCCEEDED' || res.state === 'FAILED') {
            resolve(res);
          }
          // If the condition isn't met but the timeout hasn't elapsed, go again
          else if (Number(new Date()) < endTime) {
              setTimeout(checkCondition, interval, resolve, reject);
          }
          // Didn't match and too much time, reject!
          else {
              reject(new Error('timed out for ' + fn + ': ' + arguments));
          }
        })

    };

    return new Promise(checkCondition);
  }

  poll(function() {
    return window.fetch('{{ statusApi }}');
  }, 1200000, 2000).then(function(status) {
    if (status.state === 'FAILED') {
      var target = document.getElementById('message')
      target.innerHTML = 'Something went wrong. Redirecting to pipelines page...';
      setTimeout(function() {
        window.location = '{{ failUrl }}';
      }, 1000);
    } else if (status.state === 'SUCCEEDED') {
      var target = document.getElementById('message')
      target.innerHTML = 'Success! Reloading...';
      setTimeout(function() {
        window.location = '{{ successUrl }}';
      }, 1000);
    }
  }).catch(function() {
    // Polling timed out, handle the error!
    alert('Please, reload the page...');
  });

  var opts = {
    lines: 11 // The number of lines to draw
  , length: 34 // The length of each line
  , width: 12 // The line thickness
  , radius: 42 // The radius of the inner circle<commit_msg>[status][xs]: fixed async json() method after getting response with fetch - refs #46<commit_after>{% extends "base.html" %}

{% block title %}
Uploading {{owner}}/{{name}}
{% endblock %}

{% block content %}
<div class="container">
  <div class="inner_container">
    <p id="message" class="text-center">Your data is safely stored and is getting processed - it will be here soon!</p>
    <div id="status"></div>
  </div>
</div>
<script type="text/javascript" src="/static/js/spin.min.js"></script>
<script type="text/javascript">
  // The polling function
  function poll(fn, timeout, interval) {
    var endTime = Number(new Date()) + (timeout || 2000);
    interval = interval || 100;

    var checkCondition = function(resolve, reject) {
        // If the condition is met, we're done!
        fn().then(function(res) {
          res.json().then(function(out) {
            if (out.state === 'SUCCEEDED' || out.state === 'FAILED') {
              resolve(out);
            }
            // If the condition isn't met but the timeout hasn't elapsed, go again
            else if (Number(new Date()) < endTime) {
                setTimeout(checkCondition, interval, resolve, reject);
            }
            // Didn't match and too much time, reject!
            else {
                reject(new Error('timed out for ' + fn + ': ' + arguments));
            }
          })
        })
    };

    return new Promise(checkCondition);
  }

  poll(function() {
    return window.fetch('{{ statusApi }}');
  }, 1200000, 2000).then(function(status) {
    if (status.state === 'FAILED') {
      var target = document.getElementById('message')
      target.innerHTML = 'Something went wrong. Redirecting to pipelines page...';
      setTimeout(function() {
        window.location = '{{ failUrl }}';
      }, 1000);
    } else if (status.state === 'SUCCEEDED') {
      var target = document.getElementById('message')
      target.innerHTML = 'Success! Reloading...';
      setTimeout(function() {
        window.location = '{{ successUrl }}';
      }, 1000);
    }
  }).catch(function() {
    // Polling timed out, handle the error!
    alert('Please, reload the page...');
  });

  var opts = {
    lines: 11 // The number of lines to draw
  , length: 34 // The length of each line
  , width: 12 // The line thickness
  , radius: 42 // The radius of the inner circle
{'fraction_non_alphanumeric': 0.15571085389823106, 'fraction_numerical': 0.015287180607119458, 'mean_word_length': 2.523076923076923, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4699331', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1284, 'n_words': 391}