<commit_before>$(function() {
    if ($("#discussion-info").length > 0 && $(".post").length > 0) {
        var poll_interval = parseInt($("#discussion-info").attr("data-poll-interval"), 10);
        var poll_attempts = 0;
        var poll_increment = 15000;
        var max_increments = 75; // Max is around 30 minutes

        // Set initial update timer
        $("#discussion-info-updating-in-seconds").html(poll_interval/1000);
        setTimeout(function() { updatePosts(poll_interval, poll_attempts, poll_increment, max_increments); }, poll_interval);
        setInterval(updateTimer, 1000);
    }
});

function updatePosts(poll_interval, poll_attempts, poll_increment, max_increments) {
    discussion_id = $("#discussion-info").attr("data-discussion-id");
    after = $(".post").last().attr("data-post-id");
    $.getScript("/posts/poll.js?discussion_id=" + discussion_id + "&after=" + after);

    if (after == $(".post").last().attr("data-post-id")) {
        // No new posts, increase poll interval
        poll_attempts = Math.min(poll_attempts + 1, max_increments);
    } else {
        poll_attempts = 0;
    }

    $("#discussion-info-updating-in-seconds").html((poll_interval + (poll_attempts * poll_increment))/1000);
    setTimeout(function() { updatePosts(poll_interval, poll_attempts, poll_increment, max_increments); }, poll_interval + (poll_attempts * poll_increment));
}

function updateTimer() {
    $('#discussion-info-updating-in-seconds').each( function() {
        $(this).html(parseInt($(this).html(), 10) - 1);
    });
}<commit_msg>Delay scanning for poll interval increment so it doesn't miss updates<commit_after>$(function() {
    if ($("#discussion-info").length > 0 && $(".post").length > 0) {
        var poll_interval = parseInt($("#discussion-info").attr("data-poll-interval"), 10);
        var poll_attempts = 0;
        var poll_increment = 15000;
        var max_increments = 75; // Max is around 30 minutes

        // Set initial update timer
        $("#discussion-info-updating-in-seconds").html(poll_interval/1000);
        setTimeout(function() { updatePosts(poll_interval, poll_attempts, poll_increment, max_increments); }, poll_interval);
        setInterval(updateTimer, 1000);
    }
});

function updatePosts(poll_interval, poll_attempts, poll_increment, max_increments) {
    discussion_id = $("#discussion-info").attr("data-discussion-id");
    after = $(".post").last().attr("data-post-id");
    $.getScript("/posts/poll.js?discussion_id=" + discussion_id + "&after=" + after);

    setTimeout(function() {
        if (after == $(".post").last().attr("data-post-id")) {
            // No new posts, increase poll interval
            poll_attempts = Math.min(poll_attempts + 1, max_increments);
        } else {
            poll_attempts = 0;
        }
    }, 1000);

    $("#discussion-info-updating-in-seconds").html((poll_interval + (poll_attempts * poll_increment))/1000);
    setTimeout(function() { updatePosts(poll_interval, poll_attempts, poll_increment, max_increments); }, poll_interval + (poll_attempts * poll_increment));
}

function updateTimer() {
    $('#discussion-info-updating-in-seconds').each( function() {
        $(this).html(parseInt($(this).html(), 10) - 1);
    });
}
{'fraction_non_alphanumeric': 0.16913123844731978, 'fraction_numerical': 0.02033271719038817, 'mean_word_length': 3.6319543509272467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2348678', 'n_tokens_mistral': 1074, 'n_tokens_neox': 967, 'n_words': 180}