From 54b60c23e954fd8dd997893255b813f50c43aa32 Mon Sep 17 00:00:00 2001 From: Bryan Friedman Date: Thu, 16 Jul 2026 09:59:33 -0700 Subject: [PATCH 1/2] Align report queries with the deployed Athena schema Point every report at the `traces` table rather than the placeholder `trace` name, and pin the tenant with a `` placeholder so the queries run against the injected tenant partition. Add a `type` filter to the six reports that analyze a single command stage, so partition pruning applies and stage re-emission cannot double count. Leave it off the build reports, which dedupe on buildId and would undercount if pinned to type = 'build', and off top-users, which reads run and commit columns from the same rows. Fix inflated totals in the dashboard KPIs. Both queries summed run-stage columns across every trace that re-emits them, counting a single run once per later stage. Collapse to one row per (runId, path) before aggregating. Update the affected header comments and READMEs to match the new scoping. --- .../build-success-trend.sql | 6 +- .../build-tool-distribution.sql | 11 ++-- templates/commit-activity/commit-activity.sql | 9 ++- templates/commit-trend/commit-trend.sql | 9 ++- templates/dashboard-kpis/dashboard-kpis.sql | 66 ++++++++++++++----- templates/recipe-run-trend/README.md | 2 +- .../recipe-run-trend/recipe-run-trend.sql | 9 ++- .../security-recipe-run-trend.sql | 9 ++- .../top-recipes-with-commits.sql | 9 ++- templates/top-recipes/README.md | 2 +- templates/top-recipes/top-recipes.sql | 9 ++- templates/top-users/top-users.sql | 6 +- 12 files changed, 102 insertions(+), 45 deletions(-) diff --git a/templates/build-success-trend/build-success-trend.sql b/templates/build-success-trend/build-success-trend.sql index 0905133..749330e 100644 --- a/templates/build-success-trend/build-success-trend.sql +++ b/templates/build-success-trend/build-success-trend.sql @@ -5,6 +5,7 @@ -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. +-- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(buildStartTime AS TIMESTAMP)) AS month, @@ -14,7 +15,8 @@ SELECT ROUND(100.0 * COUNT(DISTINCT CASE WHEN buildOutcome = 'Succeeded' THEN buildId END) / COUNT(DISTINCT buildId), 1) AS success_rate_pct, COUNT(DISTINCT path) AS unique_repos -FROM trace -WHERE buildOutcome IS NOT NULL +FROM traces +WHERE tenant = '' + AND buildOutcome IS NOT NULL GROUP BY DATE_TRUNC('month', CAST(buildStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/build-tool-distribution/build-tool-distribution.sql b/templates/build-tool-distribution/build-tool-distribution.sql index b3ffc09..8883110 100644 --- a/templates/build-tool-distribution/build-tool-distribution.sql +++ b/templates/build-tool-distribution/build-tool-distribution.sql @@ -6,6 +6,7 @@ -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. -- Query 1: Build tool summary — repos per build tool +-- Replace with your tenant name. SELECT CASE WHEN buildMavenVersion IS NOT NULL AND buildMavenVersion != '' THEN 'Maven' @@ -18,8 +19,9 @@ SELECT END AS build_tool, COUNT(DISTINCT path) AS repos, COUNT(DISTINCT buildId) AS builds -FROM trace -WHERE buildOutcome = 'Succeeded' +FROM traces +WHERE tenant = '' + AND buildOutcome = 'Succeeded' GROUP BY 1 ORDER BY repos DESC; @@ -45,7 +47,8 @@ SELECT ) AS tool_version, COUNT(DISTINCT path) AS repos, COUNT(DISTINCT buildId) AS builds -FROM trace -WHERE buildOutcome = 'Succeeded' +FROM traces +WHERE tenant = '' + AND buildOutcome = 'Succeeded' GROUP BY 1, 2 ORDER BY build_tool, repos DESC; diff --git a/templates/commit-activity/commit-activity.sql b/templates/commit-activity/commit-activity.sql index dc5a2cb..3aa7685 100644 --- a/templates/commit-activity/commit-activity.sql +++ b/templates/commit-activity/commit-activity.sql @@ -1,10 +1,11 @@ -- Commit Activity -- -- Monthly committed output: successful commits, repos changed, and estimated hours saved. --- Data source: mod git commit trace, or any later-stage trace. +-- Data source: mod git commit traces (type = 'commit'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. +-- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) AS month, @@ -17,8 +18,10 @@ FROM ( MAX(commitStartTime) AS commitStartTime, MAX(path) AS path, MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs - FROM trace - WHERE commitOutcome = 'Succeeded' + FROM traces + WHERE tenant = '' + AND type = 'commit' + AND commitOutcome = 'Succeeded' GROUP BY commitId ) commits GROUP BY DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) diff --git a/templates/commit-trend/commit-trend.sql b/templates/commit-trend/commit-trend.sql index f20fccb..4ad12f1 100644 --- a/templates/commit-trend/commit-trend.sql +++ b/templates/commit-trend/commit-trend.sql @@ -1,10 +1,11 @@ -- Commit Trend -- -- Monthly trend correlating recipe execution with committed code impact. --- Data source: mod git commit trace, or any later-stage trace. +-- Data source: mod git commit traces (type = 'commit'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. +-- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) AS month, @@ -15,7 +16,9 @@ SELECT COUNT(DISTINCT path) AS repos_with_commits, COUNT(DISTINCT CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS successful_commits, ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved -FROM trace -WHERE commitOutcome IS NOT NULL +FROM traces +WHERE tenant = '' + AND type = 'commit' + AND commitOutcome IS NOT NULL GROUP BY DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/dashboard-kpis/dashboard-kpis.sql b/templates/dashboard-kpis/dashboard-kpis.sql index f3b2e5b..5931315 100644 --- a/templates/dashboard-kpis/dashboard-kpis.sql +++ b/templates/dashboard-kpis/dashboard-kpis.sql @@ -4,31 +4,63 @@ -- Data source: mod git commit trace for full metrics, or mod run trace for run-only metrics. -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. +-- +-- Run-stage columns are re-emitted by every later-stage trace (apply, add, commit), so a +-- single run can appear on several rows. Both queries below first collapse to one row per +-- (runId, path) -- one repository's participation in one run -- before summing, so the +-- totals are not inflated. Counts of commits still work because the inner query keeps the +-- commit columns, which only later-stage traces carry. -- Query 1: Summary KPIs (single row, all-time totals) +-- Replace with your tenant name. SELECT - COUNT(DISTINCT runId) AS total_recipe_runs, - COUNT(DISTINCT CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS total_commits, - COUNT(DISTINCT developer) AS unique_users, - COUNT(DISTINCT runRecipeId) AS unique_recipes, - SUM(runFilesWithFixResults) AS files_changed, - ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved -FROM trace -WHERE runOutcome IS NOT NULL; + COUNT(DISTINCT runId) AS total_recipe_runs, + COUNT(DISTINCT committedCommitId) AS total_commits, + COUNT(DISTINCT developer) AS unique_users, + COUNT(DISTINCT runRecipeId) AS unique_recipes, + SUM(runFilesWithFixResults) AS files_changed, + ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved +FROM ( + SELECT + runId, + path, + MAX(developer) AS developer, + MAX(runRecipeId) AS runRecipeId, + MAX(runFilesWithFixResults) AS runFilesWithFixResults, + MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs, + MAX(CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS committedCommitId + FROM traces + WHERE tenant = '' + AND runOutcome IS NOT NULL + GROUP BY runId, path +) runs; -- Query 2: Monthly Trend -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. SELECT - DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) AS month, - COUNT(DISTINCT runId) AS recipe_runs, - COUNT(DISTINCT CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS commits, - COUNT(DISTINCT developer) AS unique_users, - COUNT(DISTINCT runRecipeId) AS unique_recipes, - SUM(runFilesWithFixResults) AS files_changed, - ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved -FROM trace -WHERE runOutcome IS NOT NULL + DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) AS month, + COUNT(DISTINCT runId) AS recipe_runs, + COUNT(DISTINCT committedCommitId) AS commits, + COUNT(DISTINCT developer) AS unique_users, + COUNT(DISTINCT runRecipeId) AS unique_recipes, + SUM(runFilesWithFixResults) AS files_changed, + ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved +FROM ( + SELECT + runId, + path, + MAX(runStartTime) AS runStartTime, + MAX(developer) AS developer, + MAX(runRecipeId) AS runRecipeId, + MAX(runFilesWithFixResults) AS runFilesWithFixResults, + MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs, + MAX(CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS committedCommitId + FROM traces + WHERE tenant = '' + AND runOutcome IS NOT NULL + GROUP BY runId, path +) runs GROUP BY DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/recipe-run-trend/README.md b/templates/recipe-run-trend/README.md index da8532c..b22c2cc 100644 --- a/templates/recipe-run-trend/README.md +++ b/templates/recipe-run-trend/README.md @@ -4,7 +4,7 @@ Monthly adoption trend showing how Moderne usage is growing over time. ## Data Source -This report uses trace data produced by **`mod run`**. Any later-stage command (`mod git apply`, `mod git commit`, `mod git push`) also includes run-stage data and will work with this query. +This report uses trace data produced by **`mod run`**. Later-stage commands (`mod git apply`, `mod git add`, `mod git commit`) re-emit the same run-stage columns, so the query pins `type = 'run'` to count each run once. See the [trace.csv data dictionary](../../data-dictionary/trace-csv.md) for the full column reference. diff --git a/templates/recipe-run-trend/recipe-run-trend.sql b/templates/recipe-run-trend/recipe-run-trend.sql index 3df78b1..06edc35 100644 --- a/templates/recipe-run-trend/recipe-run-trend.sql +++ b/templates/recipe-run-trend/recipe-run-trend.sql @@ -1,17 +1,20 @@ -- Recipe Run Trend -- -- Monthly adoption trend: recipe runs, distinct recipes, and unique users over time. --- Data source: mod run trace, or any later-stage trace. +-- Data source: mod run traces (type = 'run'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. +-- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) AS month, COUNT(DISTINCT runId) AS recipe_runs, COUNT(DISTINCT runRecipeId) AS distinct_recipes, COUNT(DISTINCT developer) AS unique_users -FROM trace -WHERE runOutcome IS NOT NULL +FROM traces +WHERE tenant = '' + AND type = 'run' + AND runOutcome IS NOT NULL GROUP BY DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/security-recipe-run-trend/security-recipe-run-trend.sql b/templates/security-recipe-run-trend/security-recipe-run-trend.sql index 5c850e5..ff1ade2 100644 --- a/templates/security-recipe-run-trend/security-recipe-run-trend.sql +++ b/templates/security-recipe-run-trend/security-recipe-run-trend.sql @@ -2,13 +2,14 @@ -- -- Monthly security remediation trend: committed fixes, repos fixed, -- files remediated, hours saved, and distinct security recipes over time. --- Data source: mod git commit trace (commit-stage traces include run-stage data). +-- Data source: mod git commit traces (type = 'commit'); they carry the run-stage columns. -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. -- -- Default filter targets recipes from rewrite-java-security and -- rewrite-static-analysis. See the README for customization guidance. +-- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) AS month, @@ -25,8 +26,10 @@ FROM ( MAX(runRecipeId) AS runRecipeId, MAX(runFilesWithFixResults) AS runFilesWithFixResults, MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs - FROM trace - WHERE commitOutcome = 'Succeeded' + FROM traces + WHERE tenant = '' + AND type = 'commit' + AND commitOutcome = 'Succeeded' AND (runRecipeId LIKE 'org.openrewrite.java.security.%' OR runRecipeId LIKE 'org.openrewrite.staticanalysis.%') GROUP BY commitId diff --git a/templates/top-recipes-with-commits/top-recipes-with-commits.sql b/templates/top-recipes-with-commits/top-recipes-with-commits.sql index 3d18868..c71cf8c 100644 --- a/templates/top-recipes-with-commits/top-recipes-with-commits.sql +++ b/templates/top-recipes-with-commits/top-recipes-with-commits.sql @@ -1,9 +1,10 @@ -- Top Recipes with Commits -- -- Recipes ranked by committed code changes — shows which recipes deliver real results. --- Data source: mod git commit trace, or any later-stage trace. +-- Data source: mod git commit traces (type = 'commit'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. +-- Replace with your tenant name. SELECT runRecipeId AS recipe_id, @@ -11,7 +12,9 @@ SELECT COUNT(DISTINCT commitId) AS commits, COUNT(DISTINCT developer) AS unique_users, ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved -FROM trace -WHERE commitOutcome = 'Succeeded' +FROM traces +WHERE tenant = '' + AND type = 'commit' + AND commitOutcome = 'Succeeded' GROUP BY runRecipeId ORDER BY commits DESC; diff --git a/templates/top-recipes/README.md b/templates/top-recipes/README.md index 70d7779..c681111 100644 --- a/templates/top-recipes/README.md +++ b/templates/top-recipes/README.md @@ -4,7 +4,7 @@ Most-used recipes ranked by run count and unique users — shows which recipes a ## Data Source -This report uses trace data produced by **`mod run`**. Any later-stage command (`mod git apply`, `mod git commit`, `mod git push`) also includes run-stage data and will work with this query. +This report uses trace data produced by **`mod run`**. Later-stage commands (`mod git apply`, `mod git add`, `mod git commit`) re-emit the same run-stage columns, so the query pins `type = 'run'` to count each run once. See the [trace.csv data dictionary](../../data-dictionary/trace-csv.md) for the full column reference. diff --git a/templates/top-recipes/top-recipes.sql b/templates/top-recipes/top-recipes.sql index 16c82ae..9b1e188 100644 --- a/templates/top-recipes/top-recipes.sql +++ b/templates/top-recipes/top-recipes.sql @@ -1,9 +1,10 @@ -- Top Recipes -- -- Most-used recipes ranked by run count, unique users, and repos searched. --- Data source: mod run trace, or any later-stage trace. +-- Data source: mod run traces (type = 'run'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. +-- Replace with your tenant name. SELECT runRecipeId AS recipe_id, @@ -11,7 +12,9 @@ SELECT COUNT(DISTINCT runId) AS recipe_runs, COUNT(DISTINCT developer) AS unique_users, COUNT(DISTINCT path) AS repos_searched -FROM trace -WHERE runOutcome IS NOT NULL +FROM traces +WHERE tenant = '' + AND type = 'run' + AND runOutcome IS NOT NULL GROUP BY runRecipeId ORDER BY recipe_runs DESC; diff --git a/templates/top-users/top-users.sql b/templates/top-users/top-users.sql index 1360596..80fb6d6 100644 --- a/templates/top-users/top-users.sql +++ b/templates/top-users/top-users.sql @@ -5,12 +5,14 @@ -- If only mod run traces are available, recipe runs will be accurate but commits will be zero. -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. +-- Replace with your tenant name. SELECT developer, COUNT(DISTINCT runId) AS recipe_runs, COUNT(DISTINCT CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS commits -FROM trace -WHERE runOutcome IS NOT NULL +FROM traces +WHERE tenant = '' + AND runOutcome IS NOT NULL GROUP BY developer ORDER BY recipe_runs DESC; From a4c0937ecee8965573f5cfae33089689d1ea01d5 Mon Sep 17 00:00:00 2001 From: Bryan Friedman Date: Fri, 17 Jul 2026 08:58:26 -0700 Subject: [PATCH 2/2] Remove tenant --- templates/build-success-trend/build-success-trend.sql | 4 +--- .../build-tool-distribution/build-tool-distribution.sql | 8 +++----- templates/commit-activity/commit-activity.sql | 4 +--- templates/commit-trend/commit-trend.sql | 4 +--- templates/dashboard-kpis/dashboard-kpis.sql | 7 ++----- templates/recipe-run-trend/recipe-run-trend.sql | 4 +--- .../security-recipe-run-trend.sql | 4 +--- .../top-recipes-with-commits/top-recipes-with-commits.sql | 4 +--- templates/top-recipes/top-recipes.sql | 4 +--- templates/top-users/top-users.sql | 4 +--- 10 files changed, 13 insertions(+), 34 deletions(-) diff --git a/templates/build-success-trend/build-success-trend.sql b/templates/build-success-trend/build-success-trend.sql index 749330e..4f76f6f 100644 --- a/templates/build-success-trend/build-success-trend.sql +++ b/templates/build-success-trend/build-success-trend.sql @@ -5,7 +5,6 @@ -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. --- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(buildStartTime AS TIMESTAMP)) AS month, @@ -16,7 +15,6 @@ SELECT / COUNT(DISTINCT buildId), 1) AS success_rate_pct, COUNT(DISTINCT path) AS unique_repos FROM traces -WHERE tenant = '' - AND buildOutcome IS NOT NULL +WHERE buildOutcome IS NOT NULL GROUP BY DATE_TRUNC('month', CAST(buildStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/build-tool-distribution/build-tool-distribution.sql b/templates/build-tool-distribution/build-tool-distribution.sql index 8883110..e9bcc27 100644 --- a/templates/build-tool-distribution/build-tool-distribution.sql +++ b/templates/build-tool-distribution/build-tool-distribution.sql @@ -6,7 +6,7 @@ -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. -- Query 1: Build tool summary — repos per build tool --- Replace with your tenant name. + SELECT CASE WHEN buildMavenVersion IS NOT NULL AND buildMavenVersion != '' THEN 'Maven' @@ -20,8 +20,7 @@ SELECT COUNT(DISTINCT path) AS repos, COUNT(DISTINCT buildId) AS builds FROM traces -WHERE tenant = '' - AND buildOutcome = 'Succeeded' +WHERE buildOutcome = 'Succeeded' GROUP BY 1 ORDER BY repos DESC; @@ -48,7 +47,6 @@ SELECT COUNT(DISTINCT path) AS repos, COUNT(DISTINCT buildId) AS builds FROM traces -WHERE tenant = '' - AND buildOutcome = 'Succeeded' +WHERE buildOutcome = 'Succeeded' GROUP BY 1, 2 ORDER BY build_tool, repos DESC; diff --git a/templates/commit-activity/commit-activity.sql b/templates/commit-activity/commit-activity.sql index 3aa7685..a694e0f 100644 --- a/templates/commit-activity/commit-activity.sql +++ b/templates/commit-activity/commit-activity.sql @@ -5,7 +5,6 @@ -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. --- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) AS month, @@ -19,8 +18,7 @@ FROM ( MAX(path) AS path, MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs FROM traces - WHERE tenant = '' - AND type = 'commit' + WHERE type = 'commit' AND commitOutcome = 'Succeeded' GROUP BY commitId ) commits diff --git a/templates/commit-trend/commit-trend.sql b/templates/commit-trend/commit-trend.sql index 4ad12f1..56825d5 100644 --- a/templates/commit-trend/commit-trend.sql +++ b/templates/commit-trend/commit-trend.sql @@ -5,7 +5,6 @@ -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. --- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) AS month, @@ -17,8 +16,7 @@ SELECT COUNT(DISTINCT CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS successful_commits, ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved FROM traces -WHERE tenant = '' - AND type = 'commit' +WHERE type = 'commit' AND commitOutcome IS NOT NULL GROUP BY DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/dashboard-kpis/dashboard-kpis.sql b/templates/dashboard-kpis/dashboard-kpis.sql index 5931315..e4f215d 100644 --- a/templates/dashboard-kpis/dashboard-kpis.sql +++ b/templates/dashboard-kpis/dashboard-kpis.sql @@ -12,7 +12,6 @@ -- commit columns, which only later-stage traces carry. -- Query 1: Summary KPIs (single row, all-time totals) --- Replace with your tenant name. SELECT COUNT(DISTINCT runId) AS total_recipe_runs, @@ -31,8 +30,7 @@ FROM ( MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs, MAX(CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS committedCommitId FROM traces - WHERE tenant = '' - AND runOutcome IS NOT NULL + WHERE runOutcome IS NOT NULL GROUP BY runId, path ) runs; @@ -58,8 +56,7 @@ FROM ( MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs, MAX(CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS committedCommitId FROM traces - WHERE tenant = '' - AND runOutcome IS NOT NULL + WHERE runOutcome IS NOT NULL GROUP BY runId, path ) runs GROUP BY DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) diff --git a/templates/recipe-run-trend/recipe-run-trend.sql b/templates/recipe-run-trend/recipe-run-trend.sql index 06edc35..3fae003 100644 --- a/templates/recipe-run-trend/recipe-run-trend.sql +++ b/templates/recipe-run-trend/recipe-run-trend.sql @@ -5,7 +5,6 @@ -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other engines supporting DATE_TRUNC. -- Replace 'month' with 'week', 'quarter', or 'year' to change granularity. --- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) AS month, @@ -13,8 +12,7 @@ SELECT COUNT(DISTINCT runRecipeId) AS distinct_recipes, COUNT(DISTINCT developer) AS unique_users FROM traces -WHERE tenant = '' - AND type = 'run' +WHERE type = 'run' AND runOutcome IS NOT NULL GROUP BY DATE_TRUNC('month', CAST(runStartTime AS TIMESTAMP)) ORDER BY month; diff --git a/templates/security-recipe-run-trend/security-recipe-run-trend.sql b/templates/security-recipe-run-trend/security-recipe-run-trend.sql index ff1ade2..854be74 100644 --- a/templates/security-recipe-run-trend/security-recipe-run-trend.sql +++ b/templates/security-recipe-run-trend/security-recipe-run-trend.sql @@ -9,7 +9,6 @@ -- -- Default filter targets recipes from rewrite-java-security and -- rewrite-static-analysis. See the README for customization guidance. --- Replace with your tenant name. SELECT DATE_TRUNC('month', CAST(commitStartTime AS TIMESTAMP)) AS month, @@ -27,8 +26,7 @@ FROM ( MAX(runFilesWithFixResults) AS runFilesWithFixResults, MAX(runEstimatedEffortTimeSavingsMs) AS runEstimatedEffortTimeSavingsMs FROM traces - WHERE tenant = '' - AND type = 'commit' + WHERE type = 'commit' AND commitOutcome = 'Succeeded' AND (runRecipeId LIKE 'org.openrewrite.java.security.%' OR runRecipeId LIKE 'org.openrewrite.staticanalysis.%') diff --git a/templates/top-recipes-with-commits/top-recipes-with-commits.sql b/templates/top-recipes-with-commits/top-recipes-with-commits.sql index c71cf8c..feedb5f 100644 --- a/templates/top-recipes-with-commits/top-recipes-with-commits.sql +++ b/templates/top-recipes-with-commits/top-recipes-with-commits.sql @@ -4,7 +4,6 @@ -- Data source: mod git commit traces (type = 'commit'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. --- Replace with your tenant name. SELECT runRecipeId AS recipe_id, @@ -13,8 +12,7 @@ SELECT COUNT(DISTINCT developer) AS unique_users, ROUND(SUM(runEstimatedEffortTimeSavingsMs) / 3600000.0, 1) AS estimated_hours_saved FROM traces -WHERE tenant = '' - AND type = 'commit' +WHERE type = 'commit' AND commitOutcome = 'Succeeded' GROUP BY runRecipeId ORDER BY commits DESC; diff --git a/templates/top-recipes/top-recipes.sql b/templates/top-recipes/top-recipes.sql index 9b1e188..33de5e3 100644 --- a/templates/top-recipes/top-recipes.sql +++ b/templates/top-recipes/top-recipes.sql @@ -4,7 +4,6 @@ -- Data source: mod run traces (type = 'run'). -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. --- Replace with your tenant name. SELECT runRecipeId AS recipe_id, @@ -13,8 +12,7 @@ SELECT COUNT(DISTINCT developer) AS unique_users, COUNT(DISTINCT path) AS repos_searched FROM traces -WHERE tenant = '' - AND type = 'run' +WHERE type = 'run' AND runOutcome IS NOT NULL GROUP BY runRecipeId ORDER BY recipe_runs DESC; diff --git a/templates/top-users/top-users.sql b/templates/top-users/top-users.sql index 80fb6d6..2009fe9 100644 --- a/templates/top-users/top-users.sql +++ b/templates/top-users/top-users.sql @@ -5,14 +5,12 @@ -- If only mod run traces are available, recipe runs will be accurate but commits will be zero. -- -- Compatible with: AWS Athena, Trino, PostgreSQL, and other standard SQL engines. --- Replace with your tenant name. SELECT developer, COUNT(DISTINCT runId) AS recipe_runs, COUNT(DISTINCT CASE WHEN commitOutcome = 'Succeeded' THEN commitId END) AS commits FROM traces -WHERE tenant = '' - AND runOutcome IS NOT NULL +WHERE runOutcome IS NOT NULL GROUP BY developer ORDER BY recipe_runs DESC;