From ec2a50f4c1952261dc12b29196ffb6c46092433f Mon Sep 17 00:00:00 2001 From: "Louis.z" Date: Sun, 29 Sep 2024 13:09:35 +0800 Subject: [PATCH 1/2] fix: improve the time filters in DORA dashboards (#8114) Co-authored-by: Startrekzky --- grafana/dashboards/DORA.json | 8 ++++---- grafana/dashboards/DORAByTeam.json | 2 +- grafana/dashboards/DORADebug.json | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/grafana/dashboards/DORA.json b/grafana/dashboards/DORA.json index 85ea67ac38c..3d3fdaa0983 100644 --- a/grafana/dashboards/DORA.json +++ b/grafana/dashboards/DORA.json @@ -962,7 +962,7 @@ "metricColumn": "none", "queryType": "randomWalk", "rawQuery": true, - "rawSql": "-- Metric 1: Number of deployments per month\nwith _deployments as(\n-- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n\tSELECT \n\t\tdate_format(deployment_finished_date,'%y/%m') as month,\n\t\tcount(cicd_deployment_id) as deployment_count\n\tFROM (\n\t\tSELECT\n\t\t\tcdc.cicd_deployment_id,\n\t\t\tmax(cdc.finished_date) as deployment_finished_date\n\t\tFROM cicd_deployment_commits cdc\n\t\tJOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id and pm.`table` = 'cicd_scopes'\n\t\tWHERE\n\t\t\tpm.project_name in (${project})\n\t\t\tand cdc.result = 'SUCCESS'\n\t\t\tand cdc.environment = 'PRODUCTION'\n\t\tGROUP BY 1\n\t\tHAVING $__timeFilter(max(cdc.finished_date))\n\t) _production_deployments\n\tGROUP BY 1\n)\n\nSELECT \n\tcm.month, \n\tcase when d.deployment_count is null then 0 else d.deployment_count end as 'Deployment Count'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _deployments d on cm.month = d.month\n\tWHERE $__timeFilter(cm.month_timestamp)", + "rawSql": "-- Metric 1: Number of deployments per month\nwith _deployments as(\n-- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n\tSELECT \n\t\tdate_format(deployment_finished_date,'%y/%m') as month,\n\t\tcount(cicd_deployment_id) as deployment_count\n\tFROM (\n\t\tSELECT\n\t\t\tcdc.cicd_deployment_id,\n\t\t\tmax(cdc.finished_date) as deployment_finished_date\n\t\tFROM cicd_deployment_commits cdc\n\t\tJOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id and pm.`table` = 'cicd_scopes'\n\t\tWHERE\n\t\t\tpm.project_name in (${project})\n\t\t\tand cdc.result = 'SUCCESS'\n\t\t\tand cdc.environment = 'PRODUCTION'\n\t\tGROUP BY 1\n\t\tHAVING $__timeFilter(max(cdc.finished_date))\n\t) _production_deployments\n\tGROUP BY 1\n)\n\nSELECT \n\tcm.month, \n\tcase when d.deployment_count is null then 0 else d.deployment_count end as 'Deployment Count'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _deployments d on cm.month = d.month\n\tWHERE month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ @@ -1095,7 +1095,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "-- Metric 2: median change lead time per month\nwith _pr_stats as (\n-- get the cycle time of PRs deployed by the deployments finished each month\n\tSELECT\n\t\tdistinct pr.id,\n\t\tdate_format(cdc.finished_date,'%y/%m') as month,\n\t\tppm.pr_cycle_time\n\tFROM\n\t\tpull_requests pr\n\t\tjoin project_pr_metrics ppm on ppm.id = pr.id\n\t\tjoin project_mapping pm on pr.base_repo_id = pm.row_id and pm.`table` = 'repos'\n\t\tjoin cicd_deployment_commits cdc on ppm.deployment_commit_id = cdc.id\n\tWHERE\n\t\tpm.project_name in (${project}) \n\t\tand pr.merged_date is not null\n\t\tand ppm.pr_cycle_time is not null\n\t\tand $__timeFilter(cdc.finished_date)\n),\n\n_find_median_clt_each_month_ranks as(\n\tSELECT *, percent_rank() over(PARTITION BY month order by pr_cycle_time) as ranks\n\tFROM _pr_stats\n),\n\n_clt as(\n\tSELECT month, max(pr_cycle_time) as median_change_lead_time\n\tFROM _find_median_clt_each_month_ranks\n\tWHERE ranks <= 0.5\n\tgroup by month\n)\n\nSELECT \n\tcm.month,\n\tcase \n\t\twhen _clt.median_change_lead_time is null then 0 \n\t\telse _clt.median_change_lead_time/60 end as 'Median Change Lead Time In Hours'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _clt on cm.month = _clt.month\n WHERE $__timeFilter(cm.month_timestamp)", + "rawSql": "-- Metric 2: median change lead time per month\nwith _pr_stats as (\n-- get the cycle time of PRs deployed by the deployments finished each month\n\tSELECT\n\t\tdistinct pr.id,\n\t\tdate_format(cdc.finished_date,'%y/%m') as month,\n\t\tppm.pr_cycle_time\n\tFROM\n\t\tpull_requests pr\n\t\tjoin project_pr_metrics ppm on ppm.id = pr.id\n\t\tjoin project_mapping pm on pr.base_repo_id = pm.row_id and pm.`table` = 'repos'\n\t\tjoin cicd_deployment_commits cdc on ppm.deployment_commit_id = cdc.id\n\tWHERE\n\t\tpm.project_name in (${project}) \n\t\tand pr.merged_date is not null\n\t\tand ppm.pr_cycle_time is not null\n\t\tand $__timeFilter(cdc.finished_date)\n),\n\n_find_median_clt_each_month_ranks as(\n\tSELECT *, percent_rank() over(PARTITION BY month order by pr_cycle_time) as ranks\n\tFROM _pr_stats\n),\n\n_clt as(\n\tSELECT month, max(pr_cycle_time) as median_change_lead_time\n\tFROM _find_median_clt_each_month_ranks\n\tWHERE ranks <= 0.5\n\tgroup by month\n)\n\nSELECT \n\tcm.month,\n\tcase \n\t\twhen _clt.median_change_lead_time is null then 0 \n\t\telse _clt.median_change_lead_time/60 end as 'Median Change Lead Time In Hours'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _clt on cm.month = _clt.month\n WHERE month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ @@ -1249,7 +1249,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "-- Metric 3: change failure rate per month\nwith _deployments as (\n -- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in (${project})\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_failure_caused_by_deployments as (\n -- calculate the number of incidents caused by each deployment\n SELECT\n d.deployment_id,\n d.deployment_finished_date,\n count(\n distinct case\n when i.id is not null then d.deployment_id\n else null\n end\n ) as has_incident\n FROM\n _deployments d\n left join project_incident_deployment_relationships pim on d.deployment_id = pim.deployment_id\n left join incidents i on pim.id = i.id\n GROUP BY\n 1,\n 2\n),\n_change_failure_rate_for_each_month as (\n SELECT\n date_format(deployment_finished_date, '%y/%m') as month,\n case\n when count(deployment_id) is null then null\n else sum(has_incident) / count(deployment_id)\n end as change_failure_rate\n FROM\n _failure_caused_by_deployments\n GROUP BY\n 1\n)\nSELECT\n cm.month,\n cfr.change_failure_rate as 'Change Failure Rate'\nFROM\n calendar_months cm\n LEFT JOIN _change_failure_rate_for_each_month cfr on cm.month = cfr.month\nWHERE\n $__timeFilter(cm.month_timestamp)", + "rawSql": "-- Metric 3: change failure rate per month\nwith _deployments as (\n -- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in (${project})\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_failure_caused_by_deployments as (\n -- calculate the number of incidents caused by each deployment\n SELECT\n d.deployment_id,\n d.deployment_finished_date,\n count(\n distinct case\n when i.id is not null then d.deployment_id\n else null\n end\n ) as has_incident\n FROM\n _deployments d\n left join project_incident_deployment_relationships pim on d.deployment_id = pim.deployment_id\n left join incidents i on pim.id = i.id\n GROUP BY\n 1,\n 2\n),\n_change_failure_rate_for_each_month as (\n SELECT\n date_format(deployment_finished_date, '%y/%m') as month,\n case\n when count(deployment_id) is null then null\n else sum(has_incident) / count(deployment_id)\n end as change_failure_rate\n FROM\n _failure_caused_by_deployments\n GROUP BY\n 1\n)\nSELECT\n cm.month,\n cfr.change_failure_rate as 'Change Failure Rate'\nFROM\n calendar_months cm\n LEFT JOIN _change_failure_rate_for_each_month cfr on cm.month = cfr.month\nWHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ @@ -1407,7 +1407,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "-- ***** 2023 report ***** --\n-- Metric 4: Failed deployment recovery time\nwith _deployments as (\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in ($project)\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_incidents_for_deployments as (\n SELECT\n i.id as incident_id,\n i.created_date as incident_create_date,\n i.resolution_date as incident_resolution_date,\n fd.deployment_id as caused_by_deployment,\n fd.deployment_finished_date,\n date_format(fd.deployment_finished_date, '%y/%m') as deployment_finished_month\n FROM\n incidents i\n left join project_incident_deployment_relationships pim on i.id = pim.id\n join _deployments fd on pim.deployment_id = fd.deployment_id\n WHERE\n $__timeFilter(i.resolution_date)\n),\n_recovery_time_ranks as (\n SELECT\n *,\n percent_rank() over(\n PARTITION BY deployment_finished_month\n order by\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as ranks\n FROM\n _incidents_for_deployments\n),\n_median_recovery_time as (\n SELECT\n deployment_finished_month,\n max(\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as median_recovery_time\n FROM\n _recovery_time_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n deployment_finished_month\n),\n_metric_recovery_time_2023_report as (\n SELECT\n cm.month,\n case\n when m.median_recovery_time is null then 0\n else m.median_recovery_time / 60\n end as median_recovery_time_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _median_recovery_time m on cm.month = m.deployment_finished_month\n WHERE\n $__timeFilter(cm.month_timestamp)\n),\n-- ***** 2021 report ***** --\n-- Metric 4: median time to restore service - MTTR\n_incidents as (\n -- get the number of incidents created each month\n SELECT\n distinct i.id,\n date_format(i.resolution_date, '%y/%m') as month,\n cast(lead_time_minutes as signed) as lead_time_minutes\n FROM\n incidents i\n join project_mapping pm on i.scope_id = pm.row_id\n and pm.`table` = i.`table`\n WHERE\n pm.project_name in (${project})\n and i.lead_time_minutes is not null\n),\n_find_median_mttr_each_month_ranks as(\n SELECT\n *,\n percent_rank() over(\n PARTITION BY month\n order by\n lead_time_minutes\n ) as ranks\n FROM\n _incidents\n),\n_mttr as(\n SELECT\n month,\n max(lead_time_minutes) as median_time_to_resolve\n FROM\n _find_median_mttr_each_month_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n month\n),\n_metric_mttr_2021_report as (\n SELECT\n cm.month,\n case\n when m.median_time_to_resolve is null then 0\n else m.median_time_to_resolve / 60\n end as median_time_to_resolve_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _mttr m on cm.month = m.month\n WHERE\n $__timeFilter(cm.month_timestamp)\n)\nSELECT\n cm.month,\n CASE\n WHEN '${dora_report}' = '2023' THEN mrt.median_recovery_time_in_hour\n WHEN '${dora_report}' = '2021' THEN mm.median_time_to_resolve_in_hour\n END AS '${title_value} In Hours'\nFROM\n calendar_months cm\n LEFT JOIN _metric_recovery_time_2023_report mrt ON cm.month = mrt.month\n LEFT JOIN _metric_mttr_2021_report mm ON cm.month = mm.month\nWHERE\n $__timeFilter(cm.month_timestamp)", + "rawSql": "-- ***** 2023 report ***** --\n-- Metric 4: Failed deployment recovery time\nwith _deployments as (\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in ($project)\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_incidents_for_deployments as (\n SELECT\n i.id as incident_id,\n i.created_date as incident_create_date,\n i.resolution_date as incident_resolution_date,\n fd.deployment_id as caused_by_deployment,\n fd.deployment_finished_date,\n date_format(fd.deployment_finished_date, '%y/%m') as deployment_finished_month\n FROM\n incidents i\n left join project_incident_deployment_relationships pim on i.id = pim.id\n join _deployments fd on pim.deployment_id = fd.deployment_id\n WHERE\n $__timeFilter(i.resolution_date)\n),\n_recovery_time_ranks as (\n SELECT\n *,\n percent_rank() over(\n PARTITION BY deployment_finished_month\n order by\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as ranks\n FROM\n _incidents_for_deployments\n),\n_median_recovery_time as (\n SELECT\n deployment_finished_month,\n max(\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as median_recovery_time\n FROM\n _recovery_time_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n deployment_finished_month\n),\n_metric_recovery_time_2023_report as (\n SELECT\n cm.month,\n case\n when m.median_recovery_time is null then 0\n else m.median_recovery_time / 60\n end as median_recovery_time_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _median_recovery_time m on cm.month = m.deployment_finished_month\n WHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))\n),\n-- ***** 2021 report ***** --\n-- Metric 4: median time to restore service - MTTR\n_incidents as (\n -- get the number of incidents created each month\n SELECT\n distinct i.id,\n date_format(i.resolution_date, '%y/%m') as month,\n cast(lead_time_minutes as signed) as lead_time_minutes\n FROM\n incidents i\n join project_mapping pm on i.scope_id = pm.row_id\n and pm.`table` = i.`table`\n WHERE\n pm.project_name in (${project})\n and i.lead_time_minutes is not null\n),\n_find_median_mttr_each_month_ranks as(\n SELECT\n *,\n percent_rank() over(\n PARTITION BY month\n order by\n lead_time_minutes\n ) as ranks\n FROM\n _incidents\n),\n_mttr as(\n SELECT\n month,\n max(lead_time_minutes) as median_time_to_resolve\n FROM\n _find_median_mttr_each_month_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n month\n),\n_metric_mttr_2021_report as (\n SELECT\n cm.month,\n case\n when m.median_time_to_resolve is null then 0\n else m.median_time_to_resolve / 60\n end as median_time_to_resolve_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _mttr m on cm.month = m.month\n WHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))\n)\nSELECT\n cm.month,\n CASE\n WHEN '${dora_report}' = '2023' THEN mrt.median_recovery_time_in_hour\n WHEN '${dora_report}' = '2021' THEN mm.median_time_to_resolve_in_hour\n END AS '${title_value} In Hours'\nFROM\n calendar_months cm\n LEFT JOIN _metric_recovery_time_2023_report mrt ON cm.month = mrt.month\n LEFT JOIN _metric_mttr_2021_report mm ON cm.month = mm.month\nWHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ diff --git a/grafana/dashboards/DORAByTeam.json b/grafana/dashboards/DORAByTeam.json index 972d11ee23e..863aaac35a1 100644 --- a/grafana/dashboards/DORAByTeam.json +++ b/grafana/dashboards/DORAByTeam.json @@ -1143,7 +1143,7 @@ "format": "table", "hide": false, "rawQuery": true, - "rawSql": "-- ***** 2023 report ***** --\n-- Metric 4: Failed deployment recovery time\nwith _deployments as (\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN commits c on cdc.commit_sha = c.sha\n join user_accounts ua on c.author_id = ua.account_id\n join users u on ua.user_id = u.id\n join team_users tu on u.id = tu.user_id\n join teams t on tu.team_id = t.id\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n t.name in (${team})\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_incidents_for_deployments as (\n SELECT\n i.id as incident_id,\n i.created_date as incident_create_date,\n i.resolution_date as incident_resolution_date,\n fd.deployment_id as caused_by_deployment,\n fd.deployment_finished_date,\n date_format(fd.deployment_finished_date, '%y/%m') as deployment_finished_month\n FROM\n incidents i\n left join project_incident_deployment_relationships pim on i.id = pim.id\n join _deployments fd on pim.deployment_id = fd.deployment_id\n WHERE\n $__timeFilter(i.resolution_date)\n),\n_recovery_time_ranks as (\n SELECT\n *,\n percent_rank() over(\n PARTITION BY deployment_finished_month\n order by\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as ranks\n FROM\n _incidents_for_deployments\n),\n_median_recovery_time as (\n SELECT\n deployment_finished_month,\n max(\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as median_recovery_time\n FROM\n _recovery_time_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n deployment_finished_month\n),\n_metric_recovery_time_2023_report as (\n SELECT\n cm.month,\n case\n when m.median_recovery_time is null then 0\n else m.median_recovery_time / 60\n end as median_recovery_time_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _median_recovery_time m on cm.month = m.deployment_finished_month\n WHERE\n $__timeFilter(cm.month_timestamp)\n),\n-- ***** 2021 report ***** --\n-- Metric 4: median time to restore service - MTTR\n_incidents as (\n -- get the number of incidents created each month\n SELECT\n distinct i.id,\n date_format(i.resolution_date, '%y/%m') as month,\n cast(lead_time_minutes as signed) as lead_time_minutes\n FROM\n incidents i\n join project_mapping pm on i.scope_id = pm.row_id\n and pm.`table` = i.`table`\n join user_accounts ua on i.assignee_id = ua.account_id\n join users u on ua.user_id = u.id\n join team_users tu on u.id = tu.user_id\n join teams t on tu.team_id = t.id\n WHERE\n t.name in (${team})\n and i.lead_time_minutes is not null\n),\n_find_median_mttr_each_month_ranks as(\n SELECT\n *,\n percent_rank() over(\n PARTITION BY month\n order by\n lead_time_minutes\n ) as ranks\n FROM\n _incidents\n),\n_mttr as(\n SELECT\n month,\n max(lead_time_minutes) as median_time_to_resolve\n FROM\n _find_median_mttr_each_month_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n month\n),\n_metric_mttr_2021_report as (\n SELECT\n cm.month,\n case\n when m.median_time_to_resolve is null then 0\n else m.median_time_to_resolve / 60\n end as median_time_to_resolve_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _mttr m on cm.month = m.month\n WHERE\n $__timeFilter(cm.month_timestamp)\n)\nSELECT\n cm.month,\n CASE\n WHEN '${dora_report}' = '2023' THEN mrt.median_recovery_time_in_hour\n WHEN '${dora_report}' = '2021' THEN mm.median_time_to_resolve_in_hour\n END AS '${title_value} In Hours'\nFROM\n calendar_months cm\n LEFT JOIN _metric_recovery_time_2023_report mrt ON cm.month = mrt.month\n LEFT JOIN _metric_mttr_2021_report mm ON cm.month = mm.month\nWHERE\n $__timeFilter(cm.month_timestamp)", + "rawSql": "-- ***** 2023 report ***** --\n-- Metric 4: Failed deployment recovery time\nwith _deployments as (\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN commits c on cdc.commit_sha = c.sha\n join user_accounts ua on c.author_id = ua.account_id\n join users u on ua.user_id = u.id\n join team_users tu on u.id = tu.user_id\n join teams t on tu.team_id = t.id\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n t.name in (${team})\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_incidents_for_deployments as (\n SELECT\n i.id as incident_id,\n i.created_date as incident_create_date,\n i.resolution_date as incident_resolution_date,\n fd.deployment_id as caused_by_deployment,\n fd.deployment_finished_date,\n date_format(fd.deployment_finished_date, '%y/%m') as deployment_finished_month\n FROM\n incidents i\n left join project_incident_deployment_relationships pim on i.id = pim.id\n join _deployments fd on pim.deployment_id = fd.deployment_id\n WHERE\n $__timeFilter(i.resolution_date)\n),\n_recovery_time_ranks as (\n SELECT\n *,\n percent_rank() over(\n PARTITION BY deployment_finished_month\n order by\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as ranks\n FROM\n _incidents_for_deployments\n),\n_median_recovery_time as (\n SELECT\n deployment_finished_month,\n max(\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as median_recovery_time\n FROM\n _recovery_time_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n deployment_finished_month\n),\n_metric_recovery_time_2023_report as (\n SELECT\n cm.month,\n case\n when m.median_recovery_time is null then 0\n else m.median_recovery_time / 60\n end as median_recovery_time_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _median_recovery_time m on cm.month = m.deployment_finished_month\n WHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))\n),\n-- ***** 2021 report ***** --\n-- Metric 4: median time to restore service - MTTR\n_incidents as (\n -- get the number of incidents created each month\n SELECT\n distinct i.id,\n date_format(i.resolution_date, '%y/%m') as month,\n cast(lead_time_minutes as signed) as lead_time_minutes\n FROM\n incidents i\n join project_mapping pm on i.scope_id = pm.row_id\n and pm.`table` = i.`table`\n join user_accounts ua on i.assignee_id = ua.account_id\n join users u on ua.user_id = u.id\n join team_users tu on u.id = tu.user_id\n join teams t on tu.team_id = t.id\n WHERE\n t.name in (${team})\n and i.lead_time_minutes is not null\n),\n_find_median_mttr_each_month_ranks as(\n SELECT\n *,\n percent_rank() over(\n PARTITION BY month\n order by\n lead_time_minutes\n ) as ranks\n FROM\n _incidents\n),\n_mttr as(\n SELECT\n month,\n max(lead_time_minutes) as median_time_to_resolve\n FROM\n _find_median_mttr_each_month_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n month\n),\n_metric_mttr_2021_report as (\n SELECT\n cm.month,\n case\n when m.median_time_to_resolve is null then 0\n else m.median_time_to_resolve / 60\n end as median_time_to_resolve_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _mttr m on cm.month = m.month\n WHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))\n)\nSELECT\n cm.month,\n CASE\n WHEN '${dora_report}' = '2023' THEN mrt.median_recovery_time_in_hour\n WHEN '${dora_report}' = '2021' THEN mm.median_time_to_resolve_in_hour\n END AS '${title_value} In Hours'\nFROM\n calendar_months cm\n LEFT JOIN _metric_recovery_time_2023_report mrt ON cm.month = mrt.month\n LEFT JOIN _metric_mttr_2021_report mm ON cm.month = mm.month\nWHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "sql": { "columns": [ diff --git a/grafana/dashboards/DORADebug.json b/grafana/dashboards/DORADebug.json index f547740bbd9..935b035c1da 100644 --- a/grafana/dashboards/DORADebug.json +++ b/grafana/dashboards/DORADebug.json @@ -557,7 +557,7 @@ "metricColumn": "none", "queryType": "randomWalk", "rawQuery": true, - "rawSql": "-- Metric 1: Number of deployments per month\nwith _deployments as(\n-- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n\tSELECT \n\t\tdate_format(deployment_finished_date,'%y/%m') as month,\n\t\tcount(cicd_deployment_id) as deployment_count\n\tFROM (\n\t\tSELECT\n\t\t\tcdc.cicd_deployment_id,\n\t\t\tmax(cdc.finished_date) as deployment_finished_date\n\t\tFROM cicd_deployment_commits cdc\n\t\tJOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id and pm.`table` = 'cicd_scopes'\n\t\tWHERE\n\t\t\tpm.project_name in (${project})\n\t\t\tand cdc.result = 'SUCCESS'\n\t\t\tand cdc.environment = 'PRODUCTION'\n\t\tGROUP BY 1\n\t\tHAVING $__timeFilter(max(cdc.finished_date))\n\t) _production_deployments\n\tGROUP BY 1\n)\n\nSELECT \n\tcm.month, \n\tcase when d.deployment_count is null then 0 else d.deployment_count end as 'Deployment Count'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _deployments d on cm.month = d.month\n\tWHERE $__timeFilter(cm.month_timestamp)", + "rawSql": "-- Metric 1: Number of deployments per month\nwith _deployments as(\n-- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n\tSELECT \n\t\tdate_format(deployment_finished_date,'%y/%m') as month,\n\t\tcount(cicd_deployment_id) as deployment_count\n\tFROM (\n\t\tSELECT\n\t\t\tcdc.cicd_deployment_id,\n\t\t\tmax(cdc.finished_date) as deployment_finished_date\n\t\tFROM cicd_deployment_commits cdc\n\t\tJOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id and pm.`table` = 'cicd_scopes'\n\t\tWHERE\n\t\t\tpm.project_name in (${project})\n\t\t\tand cdc.result = 'SUCCESS'\n\t\t\tand cdc.environment = 'PRODUCTION'\n\t\tGROUP BY 1\n\t\tHAVING $__timeFilter(max(cdc.finished_date))\n\t) _production_deployments\n\tGROUP BY 1\n)\n\nSELECT \n\tcm.month, \n\tcase when d.deployment_count is null then 0 else d.deployment_count end as 'Deployment Count'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _deployments d on cm.month = d.month\n\tWHERE month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ @@ -1466,7 +1466,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "-- Metric 2: median change lead time per month\nwith _pr_stats as (\n-- get the cycle time of PRs deployed by the deployments finished each month\n\tSELECT\n\t\tdistinct pr.id,\n\t\tdate_format(cdc.finished_date,'%y/%m') as month,\n\t\tppm.pr_cycle_time\n\tFROM\n\t\tpull_requests pr\n\t\tjoin project_pr_metrics ppm on ppm.id = pr.id\n\t\tjoin project_mapping pm on pr.base_repo_id = pm.row_id and pm.`table` = 'repos'\n\t\tjoin cicd_deployment_commits cdc on ppm.deployment_commit_id = cdc.id\n\tWHERE\n\t\tpm.project_name in (${project}) \n\t\tand pr.merged_date is not null\n\t\tand ppm.pr_cycle_time is not null\n\t\tand $__timeFilter(cdc.finished_date)\n),\n\n_find_median_clt_each_month_ranks as(\n\tSELECT *, percent_rank() over(PARTITION BY month order by pr_cycle_time) as ranks\n\tFROM _pr_stats\n),\n\n_clt as(\n\tSELECT month, max(pr_cycle_time) as median_change_lead_time\n\tFROM _find_median_clt_each_month_ranks\n\tWHERE ranks <= 0.5\n\tgroup by month\n)\n\nSELECT \n\tcm.month,\n\tcase \n\t\twhen _clt.median_change_lead_time is null then 0 \n\t\telse _clt.median_change_lead_time/60 end as 'Median Change Lead Time In Hour'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _clt on cm.month = _clt.month\n WHERE $__timeFilter(cm.month_timestamp)", + "rawSql": "-- Metric 2: median change lead time per month\nwith _pr_stats as (\n-- get the cycle time of PRs deployed by the deployments finished each month\n\tSELECT\n\t\tdistinct pr.id,\n\t\tdate_format(cdc.finished_date,'%y/%m') as month,\n\t\tppm.pr_cycle_time\n\tFROM\n\t\tpull_requests pr\n\t\tjoin project_pr_metrics ppm on ppm.id = pr.id\n\t\tjoin project_mapping pm on pr.base_repo_id = pm.row_id and pm.`table` = 'repos'\n\t\tjoin cicd_deployment_commits cdc on ppm.deployment_commit_id = cdc.id\n\tWHERE\n\t\tpm.project_name in (${project}) \n\t\tand pr.merged_date is not null\n\t\tand ppm.pr_cycle_time is not null\n\t\tand $__timeFilter(cdc.finished_date)\n),\n\n_find_median_clt_each_month_ranks as(\n\tSELECT *, percent_rank() over(PARTITION BY month order by pr_cycle_time) as ranks\n\tFROM _pr_stats\n),\n\n_clt as(\n\tSELECT month, max(pr_cycle_time) as median_change_lead_time\n\tFROM _find_median_clt_each_month_ranks\n\tWHERE ranks <= 0.5\n\tgroup by month\n)\n\nSELECT \n\tcm.month,\n\tcase \n\t\twhen _clt.median_change_lead_time is null then 0 \n\t\telse _clt.median_change_lead_time/60 end as 'Median Change Lead Time In Hour'\nFROM \n\tcalendar_months cm\n\tLEFT JOIN _clt on cm.month = _clt.month\n WHERE month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ @@ -3210,7 +3210,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "-- ***** 2023 report ***** --\n-- Metric 4: Failed deployment recovery time\nwith _deployments as (\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in ($project)\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_incidents_for_deployments as (\n SELECT\n i.id as incident_id,\n i.created_date as incident_create_date,\n i.resolution_date as incident_resolution_date,\n fd.deployment_id as caused_by_deployment,\n fd.deployment_finished_date,\n date_format(fd.deployment_finished_date, '%y/%m') as deployment_finished_month\n FROM\n incidents i\n left join project_incident_deployment_relationships pim on i.id = pim.id\n join _deployments fd on pim.deployment_id = fd.deployment_id\n WHERE\n $__timeFilter(i.resolution_date)\n),\n_recovery_time_ranks as (\n SELECT\n *,\n percent_rank() over(\n PARTITION BY deployment_finished_month\n order by\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as ranks\n FROM\n _incidents_for_deployments\n),\n_median_recovery_time as (\n SELECT\n deployment_finished_month,\n max(\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as median_recovery_time\n FROM\n _recovery_time_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n deployment_finished_month\n),\n_metric_recovery_time_2023_report as (\n SELECT\n cm.month,\n case\n when m.median_recovery_time is null then 0\n else m.median_recovery_time / 60\n end as median_recovery_time_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _median_recovery_time m on cm.month = m.deployment_finished_month\n WHERE\n $__timeFilter(cm.month_timestamp)\n),\n-- ***** 2021 report ***** --\n-- Metric 4: median time to restore service - MTTR\n_incidents as (\n -- get the number of incidents created each month\n SELECT\n distinct i.id,\n date_format(i.created_date, '%y/%m') as month,\n cast(lead_time_minutes as signed) as lead_time_minutes\n FROM\n incidents i\n join project_mapping pm on i.scope_id = pm.row_id\n and pm.`table` = i.`table`\n WHERE\n pm.project_name in (${project})\n and i.lead_time_minutes is not null\n),\n_find_median_mttr_each_month_ranks as(\n SELECT\n *,\n percent_rank() over(\n PARTITION BY month\n order by\n lead_time_minutes\n ) as ranks\n FROM\n _incidents\n),\n_mttr as(\n SELECT\n month,\n max(lead_time_minutes) as median_time_to_resolve\n FROM\n _find_median_mttr_each_month_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n month\n),\n_metric_mttr_2021_report as (\n SELECT\n cm.month,\n case\n when m.median_time_to_resolve is null then 0\n else m.median_time_to_resolve / 60\n end as median_time_to_resolve_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _mttr m on cm.month = m.month\n WHERE\n $__timeFilter(cm.month_timestamp)\n)\nSELECT\n cm.month,\n CASE\n WHEN '${dora_report}' = '2023' THEN mrt.median_recovery_time_in_hour\n WHEN '${dora_report}' = '2021' THEN mm.median_time_to_resolve_in_hour\n END AS '${title_value} In Hours'\nFROM\n calendar_months cm\n LEFT JOIN _metric_recovery_time_2023_report mrt ON cm.month = mrt.month\n LEFT JOIN _metric_mttr_2021_report mm ON cm.month = mm.month\nWHERE\n $__timeFilter(cm.month_timestamp)", + "rawSql": "-- ***** 2023 report ***** --\n-- Metric 4: Failed deployment recovery time\nwith _deployments as (\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in ($project)\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_incidents_for_deployments as (\n SELECT\n i.id as incident_id,\n i.created_date as incident_create_date,\n i.resolution_date as incident_resolution_date,\n fd.deployment_id as caused_by_deployment,\n fd.deployment_finished_date,\n date_format(fd.deployment_finished_date, '%y/%m') as deployment_finished_month\n FROM\n incidents i\n left join project_incident_deployment_relationships pim on i.id = pim.id\n join _deployments fd on pim.deployment_id = fd.deployment_id\n WHERE\n $__timeFilter(i.resolution_date)\n),\n_recovery_time_ranks as (\n SELECT\n *,\n percent_rank() over(\n PARTITION BY deployment_finished_month\n order by\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as ranks\n FROM\n _incidents_for_deployments\n),\n_median_recovery_time as (\n SELECT\n deployment_finished_month,\n max(\n TIMESTAMPDIFF(\n MINUTE,\n deployment_finished_date,\n incident_resolution_date\n )\n ) as median_recovery_time\n FROM\n _recovery_time_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n deployment_finished_month\n),\n_metric_recovery_time_2023_report as (\n SELECT\n cm.month,\n case\n when m.median_recovery_time is null then 0\n else m.median_recovery_time / 60\n end as median_recovery_time_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _median_recovery_time m on cm.month = m.deployment_finished_month\n WHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))\n),\n-- ***** 2021 report ***** --\n-- Metric 4: median time to restore service - MTTR\n_incidents as (\n -- get the number of incidents created each month\n SELECT\n distinct i.id,\n date_format(i.created_date, '%y/%m') as month,\n cast(lead_time_minutes as signed) as lead_time_minutes\n FROM\n incidents i\n join project_mapping pm on i.scope_id = pm.row_id\n and pm.`table` = i.`table`\n WHERE\n pm.project_name in (${project})\n and i.lead_time_minutes is not null\n),\n_find_median_mttr_each_month_ranks as(\n SELECT\n *,\n percent_rank() over(\n PARTITION BY month\n order by\n lead_time_minutes\n ) as ranks\n FROM\n _incidents\n),\n_mttr as(\n SELECT\n month,\n max(lead_time_minutes) as median_time_to_resolve\n FROM\n _find_median_mttr_each_month_ranks\n WHERE\n ranks <= 0.5\n GROUP BY\n month\n),\n_metric_mttr_2021_report as (\n SELECT\n cm.month,\n case\n when m.median_time_to_resolve is null then 0\n else m.median_time_to_resolve / 60\n end as median_time_to_resolve_in_hour\n FROM\n calendar_months cm\n LEFT JOIN _mttr m on cm.month = m.month\n WHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))\n)\nSELECT\n cm.month,\n CASE\n WHEN '${dora_report}' = '2023' THEN mrt.median_recovery_time_in_hour\n WHEN '${dora_report}' = '2021' THEN mm.median_time_to_resolve_in_hour\n END AS '${title_value} In Hours'\nFROM\n calendar_months cm\n LEFT JOIN _metric_recovery_time_2023_report mrt ON cm.month = mrt.month\n LEFT JOIN _metric_mttr_2021_report mm ON cm.month = mm.month\nWHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ @@ -3711,7 +3711,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "-- Metric 3: change failure rate per month\nwith _deployments as (\n -- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in (${project})\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_failure_caused_by_deployments as (\n -- calculate the number of incidents caused by each deployment\n SELECT\n d.deployment_id,\n d.deployment_finished_date,\n count(\n distinct case\n when i.id is not null then d.deployment_id\n else null\n end\n ) as has_incident\n FROM\n _deployments d\n left join project_incident_deployment_relationships pim on d.deployment_id = pim.deployment_id\n left join incidents i on pim.id = i.id\n GROUP BY\n 1,\n 2\n),\n_change_failure_rate_for_each_month as (\n SELECT\n date_format(deployment_finished_date, '%y/%m') as month,\n case\n when count(deployment_id) is null then null\n else sum(has_incident) / count(deployment_id)\n end as change_failure_rate\n FROM\n _failure_caused_by_deployments\n GROUP BY\n 1\n)\nSELECT\n cm.month,\n cfr.change_failure_rate as 'Change Failure Rate'\nFROM\n calendar_months cm\n LEFT JOIN _change_failure_rate_for_each_month cfr on cm.month = cfr.month\nWHERE\n $__timeFilter(cm.month_timestamp)", + "rawSql": "-- Metric 3: change failure rate per month\nwith _deployments as (\n -- When deploying multiple commits in one pipeline, GitLab and BitBucket may generate more than one deployment. However, DevLake consider these deployments as ONE production deployment and use the last one's finished_date as the finished date.\n SELECT\n cdc.cicd_deployment_id as deployment_id,\n max(cdc.finished_date) as deployment_finished_date\n FROM\n cicd_deployment_commits cdc\n JOIN project_mapping pm on cdc.cicd_scope_id = pm.row_id\n and pm.`table` = 'cicd_scopes'\n WHERE\n pm.project_name in (${project})\n and cdc.result = 'SUCCESS'\n and cdc.environment = 'PRODUCTION'\n GROUP BY\n 1\n HAVING\n $__timeFilter(max(cdc.finished_date))\n),\n_failure_caused_by_deployments as (\n -- calculate the number of incidents caused by each deployment\n SELECT\n d.deployment_id,\n d.deployment_finished_date,\n count(\n distinct case\n when i.id is not null then d.deployment_id\n else null\n end\n ) as has_incident\n FROM\n _deployments d\n left join project_incident_deployment_relationships pim on d.deployment_id = pim.deployment_id\n left join incidents i on pim.id = i.id\n GROUP BY\n 1,\n 2\n),\n_change_failure_rate_for_each_month as (\n SELECT\n date_format(deployment_finished_date, '%y/%m') as month,\n case\n when count(deployment_id) is null then null\n else sum(has_incident) / count(deployment_id)\n end as change_failure_rate\n FROM\n _failure_caused_by_deployments\n GROUP BY\n 1\n)\nSELECT\n cm.month,\n cfr.change_failure_rate as 'Change Failure Rate'\nFROM\n calendar_months cm\n LEFT JOIN _change_failure_rate_for_each_month cfr on cm.month = cfr.month\nWHERE\n month_timestamp between DATE(DATE_FORMAT($__timeFrom(), '%Y-%m-01')) AND DATE(DATE_FORMAT($__timeTo(), '%Y-%m-01'))", "refId": "A", "select": [ [ From 47a9fcd68b2135114ed9d85d409f34f28950541e Mon Sep 17 00:00:00 2001 From: Lynwee <1507509064@qq.com> Date: Mon, 30 Sep 2024 09:46:52 +0800 Subject: [PATCH 2/2] fix(zentao): make `gitcommited` a valiad action (#8115) --- backend/plugins/zentao/tasks/bug_commits_extractor.go | 4 ++-- backend/plugins/zentao/tasks/story_commits_extractor.go | 4 ++-- backend/plugins/zentao/tasks/task_commits_extractor.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/plugins/zentao/tasks/bug_commits_extractor.go b/backend/plugins/zentao/tasks/bug_commits_extractor.go index 6a634557ad0..66d17a395ec 100644 --- a/backend/plugins/zentao/tasks/bug_commits_extractor.go +++ b/backend/plugins/zentao/tasks/bug_commits_extractor.go @@ -60,8 +60,8 @@ func ExtractBugCommits(taskCtx plugin.SubTaskContext) errors.Error { if err != nil { return nil, errors.Default.WrapRaw(err) } - // only linked2revision action is valid - if res.Action != "linked2revision" { + // only linked2revision and gitcommited action is valid + if res.Action != "linked2revision" && res.Action != "gitcommited" { return nil, nil } diff --git a/backend/plugins/zentao/tasks/story_commits_extractor.go b/backend/plugins/zentao/tasks/story_commits_extractor.go index 4a5d133da53..91f1d3fa1ee 100644 --- a/backend/plugins/zentao/tasks/story_commits_extractor.go +++ b/backend/plugins/zentao/tasks/story_commits_extractor.go @@ -56,8 +56,8 @@ func ExtractStoryCommits(taskCtx plugin.SubTaskContext) errors.Error { return nil, errors.Default.WrapRaw(err) } - // only linked2revision action is valid - if res.Action != "linked2revision" { + // only linked2revision and gitcommited action is valid + if res.Action != "linked2revision" && res.Action != "gitcommited" { return nil, nil } diff --git a/backend/plugins/zentao/tasks/task_commits_extractor.go b/backend/plugins/zentao/tasks/task_commits_extractor.go index 5f52c3ebcf8..c2f2bf15771 100644 --- a/backend/plugins/zentao/tasks/task_commits_extractor.go +++ b/backend/plugins/zentao/tasks/task_commits_extractor.go @@ -56,8 +56,8 @@ func ExtractTaskCommits(taskCtx plugin.SubTaskContext) errors.Error { return nil, errors.Default.WrapRaw(err) } - // only linked2revision action is valid - if res.Action != "linked2revision" { + // only linked2revision and gitcommited action is valid + if res.Action != "linked2revision" && res.Action != "gitcommited" { return nil, nil }