<commit_before>$(function() {
    var xValue = 0,
        yValue = 0,
        zValue = 0,
        $my_count = $("#my-count"),
        $all_count = $("#all-count"),
        $interval = $("#interval"),
        count = Number($my_count.text());

    window.addEventListener("devicemotion", function (event) {
        var x = Math.round(event.acceleration.x * 10) / 10;
        var y = Math.round(event.acceleration.y * 10) / 10;
        var z = Math.round(event.acceleration.z * 10) / 10;

        if ((Math.abs(xValue - x) > 2.5) || (Math.abs(yValue - y) > 2.5) || (Math.abs(zValue - z) > 2.5)) {
            count++;
        }

        // Update the value
        xValue = x;
        yValue = y;
        zValue = z;

        $my_count.text(String(count));
        $interval.text(event.interval);
    }, true);

    setInterval(function() {
        $.post(
        '/api',
        {'count': count},
        function(response) {
            count = response.yours;
            $all_count.text(String(response.all));
        })
    }, 3000); // TODO: 負荷の見積もりに応じて適切な値に
});<commit_msg>閾値が低すぎた、あとリファクタリング<commit_after>$(function() {
    var THRESHOLD = 12.0,
        old_values = { x: 0, y: 0, z: 0 },
        $my_count = $("#my-count"),
        $all_count = $("#all-count"),
        $interval = $("#interval"),
        count = Number($my_count.text());

    window.addEventListener("devicemotion", function(event) {
        var values = {},
            acceleration = event.acceleration;

        Object.keys(acceleration).forEach(function(key) {
            values[key] = Math.round(acceleration[key] * 10) / 10;
        });

        var isShaken = Object.keys(values).some(function(key) {
            return Math.abs(values[key] - old_values[key]) > THRESHOLD;
        });
        if (isShaken)
            count++;

        // Update the value
        old_values = values;

        $my_count.text(String(count));
        $interval.text(event.interval);
    }, true);

    setInterval(function() {
        $.post(
        '/api',
        { 'count': count },
        function(response) {
            count = response.yours;
            $all_count.text(String(response.all));
        })
    }, 3000); // TODO: 負荷の見積もりに応じて適切な値に
});
{'fraction_non_alphanumeric': 0.16861510791366907, 'fraction_numerical': 0.01753597122302158, 'mean_word_length': 1.923784494086728, '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': '58944', 'n_tokens_mistral': 802, 'n_tokens_neox': 743, 'n_words': 129}