<commit_before>const apiOffline = { News: "/news" };

const teacherLoggedIn = {
  Problems: "/problems",
  Shell: "/shell",
  Scoreboard: "/scoreboard",
  Classroom: "/classroom",
  News: "/news"
};

const teacherLoggedInNoCompetition = {
  Scoreboard: "/scoreboard",
  Classroom: "/classroom",
  News: "/news"
};

const userLoggedIn = {
  Problems: "/problems",
  Shell: "/shell",
  Scoreboard: "/scoreboard",
  News: "/news"
};

const userLoggedInNoCompetition = {
  Scoreboard: "/scoreboard",
  News: "/news"
};

const userNotLoggedIn = { News: "/news" };

const adminLoggedIn = { Management: "/management" };

const loadNavbar = function(renderNavbarLinks, renderNestedNavbarLinks) {
  const navbarLayout = {
    renderNavbarLinks,
    renderNestedNavbarLinks
  };

  addAjaxListener("loadNavBar", "/api/v1/user", userData => {   // onsuccess
    addAjaxListener("loadNavBar", "/api/v1/status", competitionData => {  // onsuccess
        navbarLayout.links = userNotLoggedIn;
        navbarLayout.status = userData;
        navbarLayout.topLevel = true;
        if (userData["logged_in"]) {
          if (userData["teacher"]) {
            if (competitionData["competition_active"]) {
              navbarLayout.links = teacherLoggedIn;
            } else {
              navbarLayout.links = teacherLoggedInNoCompetition;
            }
          } else {
            if (competitionData["competition_active"]) {
              navbarLayout.links = userLoggedIn;
            } else {
              navbarLayout.links = userLoggedInNoCompetition;
            }
          }
          if (userData["admin"]) {
            $.extend(navbarLayout.links, adminLoggedIn);
          }
        } else {
          $(".show-when-logged-out").css("display", "inline-block");
        }
        $("#navbar-links").html(renderNavbarLinks(navbarLayout));
        $("#navbar-item-logout").on("click", logout);
      }, () => {     // on fail
        navbarLayout.links = apiOffline;
        $("#navbar-links").html(renderNavbarLinks(navbarLayout));
      })
  }, () => {   // on fail
      navbarLayout.links = apiOffline;
      $("#navbar-links").html(renderNavbarLinks(navbarLayout));
    });
};

$(function() {
  const renderNavbarLinks = _.template(
    $("#navbar-links-template")
      .remove()
      .text()
  );
  const renderNestedNavbarLinks = _.template(
    $("#navbar-links-dropdown-template")
      .remove()
      .text()
  );

  loadNavbar(window.renderNavbarLinks, window.renderNestedNavbarLinks);
});
<commit_msg>Add timer to update score every 60s<commit_after>const apiOffline = { News: "/news" };

const teacherLoggedIn = {
  Problems: "/problems",
  Shell: "/shell",
  Scoreboard: "/scoreboard",
  Classroom: "/classroom",
  News: "/news"
};

const teacherLoggedInNoCompetition = {
  Scoreboard: "/scoreboard",
  Classroom: "/classroom",
  News: "/news"
};

const userLoggedIn = {
  Problems: "/problems",
  Shell: "/shell",
  Scoreboard: "/scoreboard",
  News: "/news"
};

const userLoggedInNoCompetition = {
  Scoreboard: "/scoreboard",
  News: "/news"
};

const userNotLoggedIn = { News: "/news" };

const adminLoggedIn = { Management: "/management" };

const loadNavbar = function(renderNavbarLinks, renderNestedNavbarLinks) {
  const navbarLayout = {
    renderNavbarLinks,
    renderNestedNavbarLinks
  };

  addAjaxListener("loadNavBar", "/api/v1/user", userData => {   // onsuccess
    addAjaxListener("loadNavBar", "/api/v1/status", competitionData => {  // onsuccess
        navbarLayout.links = userNotLoggedIn;
        navbarLayout.status = userData;
        navbarLayout.topLevel = true;
        if (userData["logged_in"]) {
          if (userData["teacher"]) {
            if (competitionData["competition_active"]) {
              navbarLayout.links = teacherLoggedIn;
            } else {
              navbarLayout.links = teacherLoggedInNoCompetition;
            }
          } else {
            if (competitionData["competition_active"]) {
              navbarLayout.links = userLoggedIn;
            } else {
              navbarLayout.links = userLoggedInNoCompetition;
            }
          }
          if (userData["admin"]) {
            $.extend(navbarLayout.links, adminLoggedIn);
          }
        } else {
          $(".show-when-logged-out").css("display", "inline-block");
        }
        $("#navbar-links").html(renderNavbarLinks(navbarLayout));
        $("#navbar-item-logout").on("click", logout);
      }, () => {     // on fail
        navbarLayout.links = apiOffline;
        $("#navbar-links").html(renderNavbarLinks(navbarLayout));
      })
  }, () => {   // on fail
      navbarLayout.links = apiOffline;
      $("#navbar-links").html(renderNavbarLinks(navbarLayout));
    });
};

$(function() {
  const renderNavbarLinks = _.template(
    $("#navbar-links-template")
      .remove()
      .text()
  );
  const renderNestedNavbarLinks = _.template(
    $("#navbar-links-dropdown-template")
      .remove()
      .text()
  );

  loadNavbar(renderNavbarLinks, renderNestedNavbarLinks);
  window.scoreUpdateTimer = setInterval(() => {
    apiCall("GET", "/api/v1/user").done(() => {
      loadNavbar(renderNavbarLinks, renderNestedNavbarLinks);
    })
  }, 60 * 1000)
});

{'fraction_non_alphanumeric': 0.15259429446678155, 'fraction_numerical': 0.002488991001340226, 'mean_word_length': 2.6736990154711675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1982378', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1585, 'n_words': 262}