@@ -4,7 +4,7 @@ import dedent from "dedent";
44export class GithubReporter {
55 private static readonly REVIEW_COMMENT_SUFFIX = "<!-- qd-review-comment -->" ;
66 prNumber ?: number ;
7- constructor ( private readonly githubToken : string ) {
7+ constructor ( private readonly githubToken ? : string ) {
88 this . prNumber = github . context . payload . pull_request ?. number ;
99 }
1010
@@ -13,6 +13,10 @@ export class GithubReporter {
1313 console . warn ( `Not a PR, skipping report...` ) ;
1414 return ;
1515 }
16+ if ( ! this . githubToken ) {
17+ console . warn ( `No GitHub token provided, skipping report...` ) ;
18+ return ;
19+ }
1620 const octokit = github . getOctokit ( this . githubToken ) ;
1721 // check if a review from us already exists
1822 const reviews = await octokit . rest . pulls . listReviews ( {
@@ -32,10 +36,13 @@ export class GithubReporter {
3236 <details>
3337 <summary>Optimized query cost (${ r . baseCost } -> ${
3438 r . optimizedCost
35- } ) by <b>${ ( ( ( r . baseCost - r . optimizedCost ) / r . baseCost ) * 100 ) . toFixed (
36- 2
37- ) } %</b></summary>
39+ } ) by <strong>${ (
40+ ( ( r . baseCost - r . optimizedCost ) / r . baseCost ) *
41+ 100
42+ ) . toFixed ( 2 ) } %</strong></summary>
43+ \`\`\`sql
3844 ${ r . formattedQuery }
45+ \`\`\`
3946
4047 Base cost: ${ r . baseCost }
4148 Optimized cost: ${ r . optimizedCost }
@@ -65,8 +72,7 @@ export class GithubReporter {
6572 ` ;
6673 } else {
6774 review = dedent `
68- # Your queries are already optimized!
69- We didn't find any queries that could be optimized. Keep up the good work!
75+ # Your queries are optimized!
7076 ${ GithubReporter . REVIEW_COMMENT_SUFFIX }
7177 ` ;
7278 }
0 commit comments