LinearB metrics comparison

Add metrics WW is striving for

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         LinearB metrics comparison
// @author       Rolandas Valantinas
// @description  Add metrics WW is striving for
// @include      *app.linearb.io/performance*
// @namespace    https://greasyfork.org/users/157178
// @require      https://code.jquery.com/jquery-3.2.1.min.js
// @supportURL   https://github.com/rolandas-valantinas/gists/issues
// @version      1.6
// ==/UserScript==

(function () {
    var metricsButton = `<input type="button" id="add-ww-metrics" value="Add WW Metrics">`;
    var intervalButton = setInterval(addButton, 2000);
    var attempts = 0;

    function appendData(title, value) {
        $("p[data-cy='"+title+"']").append(value);
    };

    function addMetrics() {
        console.log('add addMetrics');

        appendData('coding-time-graph-value', ' / <24h');
        appendData('pickup-time-graph-value', ' / <12h');
        appendData('review-time-graph-value', ' / <4h');
        appendData('prs-opened-graph-value', ' / >2 per day');
        appendData('pr-size-graph-value', ' / <500');
        appendData('review-depth-graph-value', ' / 2-4');
        appendData('new-code-graph-value', ' / >70%');
        appendData('refactor-graph-value', ' / <25%');
        appendData('rework-graph-value', ' / <5%');

        appendData('cycle-time-graph-value', ' / <2 days');
        appendData('deploy-frequency-graph-value', ' / >1 per day');
        appendData('deploy-time-graph-value', ' / <6h');
        appendData('mttr-graph-value', ' / <4h');
    }


    function addButton() {
        console.log('add button');
        attempts++;
        var toolbar = $("div[data-cy='Dashboard-data-cy']");
        console.log(toolbar);

        if (toolbar.length > 0) {
            toolbar.append(metricsButton);
            $('#add-ww-metrics').click(addMetrics);
            attempts = 10;
            console.log('button added');
        }

        if (attempts > 5) {
            clearInterval(intervalButton);
        }
    }
})();