The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Make claude code review bot delete old comments (#64544)
Cam Saul0ee3c2ffaec2
diff --git a/.github/workflows/claude-code-review.yaml b/.github/workflows/claude-code-review.yamlindex ba4570f8b77..7566bc6fb45 100644--- a/.github/workflows/claude-code-review.yaml+++ b/.github/workflows/claude-code-review.yaml@@ -22,6 +22,32 @@ jobs:with:fetch-depth: 1+ # Apparently comments on specific lines and top-level comments about the PR as a whole are TWO TOTALLY DIFFERENT+ # TYPES OF THINGS. So we have to fetch and delete separately.+ - name: Delete old Claude PR review comments+ env:+ GH_TOKEN: ${{ github.token }}+ REPO: ${{ github.repository }}+ PR_NUMBER: ${{ github.event.pull_request.number }}+ shell: bash+ run: |+ # Get old comment IDs from the bot+ old_line_comment_ids=$(gh api "/repos/$REPO/pulls/$PR_NUMBER/comments" --jq '.[] | select(.user.login=="metabase-bot[bot]") | .id')+ echo "Deleting line comments: $old_line_comment_ids"+ # Delete each comment+ for id in $old_line_comment_ids; do+ gh api -X DELETE "/repos/$REPO/pulls/comments/$id"+ echo "Deleted line comment $id"+ done+ # Get old top-level comment IDs (technically "issue" comments on the PR?)+ old_top_level_comment_ids=$(gh api "/repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login=="metabase-bot[bot]") | .id')+ echo "Deleting top-level comments: $old_top_level_comment_ids"+ # Delete each comment+ for id in $old_top_level_comment_ids; do+ gh api -X DELETE "/repos/$REPO/issues/comments/$id"+ echo "Deleted top-level comment $id"+ done+- name: Generate GitHub App Token for Claudeuses: actions/create-github-app-token@v1id: claude-app-tokendiff --git a/CLAUDE.md b/CLAUDE.mdindex d1f79fa280c..332876102e8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -198,6 +198,9 @@ Review pull requests with a focus on:the changes in the code. **Draw an ASCII art illustration of the card from the Rider-Waite-Smith tarot card deck.(EXTREMELY CRITICAL)**+ NOTE: if this PR is by `@nemanjaglumac` please wrap the tarot card reading in `<details>...</details>` so he doesn't+ have to see it.+- Do not post comments about missing parentheses.- Include today's lucky lottery numbers in at the end of every code review.@@ -333,6 +336,24 @@ Review pull requests with a focus on:- Make sure to update comments and docstrings when you change the code they describe.+- Docstrings should be indented two spaces.++ ```clj+ ;;; BAD+ (defn update-transform-tags!+ "Update the tags associated with a transform using smart diff logic.+ Only modifies what has changed: deletes removed tags, updates positions for moved tags,+ and inserts new tags. Duplicate tag IDs are automatically deduplicated."+ ...)++ ;;; GOOD+ (defn update-transform-tags!+ "Update the tags associated with a transform using smart diff logic.+ Only modifies what has changed: deletes removed tags, updates positions for moved tags,+ and inserts new tags. Duplicate tag IDs are automatically deduplicated."+ ...)+ ```+- Write heading comments with four semicolons. Those typically serve to outline/separate major section of code, or todescribe important ideas. Often you’d have a section comment followed by a bunch of top-level comments.(https://guide.clojure.style/#four-semicolons-for-heading-comments)@@ -519,6 +540,9 @@ Review pull requests with a focus on:`.core` should import stuff with Potemkin/ `metabase.util.namespace` and not be used inside the module itself. It’salso nice to put a `:consistent-alias` entry for this namespace in the Kondo config.+- The `<module>.core` namespace should generally be empty other than importing things from other namespaces with+ Potemkin (`potemkin/import-vars` and the like).+- Put Toucan models related to a feature in `<module>.models.*` and add mappings in `metabase.models.resolution`.- Put scheduled Quartz tasks in `<module>.task.*`.@@ -552,7 +576,8 @@ Review pull requests with a focus on:### REST API Endpoints-- All new REST API Endpoints (defined by `defendpoint`) should have a response schema.+- All new REST API Endpoints (defined by `defendpoint`) should have a response schema (denoted by `:- <schema>` after+ the route string).```clj;;; BAD@@ -566,8 +591,16 @@ Review pull requests with a focus on:...)```-- REST API routes should use `kebab-case`, e.g. `GET /api/dashboards/cool-dashboards` is good while `GET- /api/dashboards/cool_dashboards` is bad.+- REST API route strings (the second arg to `defendpoint`) should use `kebab-case`, e.g. `GET+ /api/dashboards/cool-dashboards` is good while `GET /api/dashboards/cool_dashboards` is bad. More examples:++ ```clj+ ;;; Bad+ (api.macros/defendpoint :post "/check_transform" ...)++ ;;; Good+ (api.macros/defendpoint :post "/check-transform" ...)+ ```- Query parameters should also use kebab-case e.g. `GET /api/dashboards?include-archived=true` is good while `GET/api/dashboards?include_archived=true` or `GET /api/dashboards?includeArchived=true` is bad.@@ -586,6 +619,49 @@ Review pull requests with a focus on:methods in the API endpoints themselves -- a `GET /api/x/:id` endpoint should basically just be `(t2/select-one:model/Whatever id)` with maybe a perms check and some hydration sprinkled on top of this.+- All API endpoints should have Malli schemas for any parameters that aren't ignored. `_route-params` doesn't need a+ schema, but `{:keys [x]}` should have one.++- Malli schemas for REST API endpoints should be detailed enough that someone can look at them and know how to use the+ endpoint.++ Example: for an endpoint like this:++ ```clj+ (api.macros/defendpoint :post "/check_transform"+ "Check a proposed edit to a transform, and return the card, transform, etc. IDs for things that will break."+ [_route-params+ _query-params+ {:keys [id source target] :as _body} :- ::transform-body]+ ...)+ ```++ This is a bad schema for the request body:++ ```clj+ ;;; Bad, does not specify the shape of :source and :target in any real detail+ (mr/def ::transform-body+ [:map+ [:id {:optional false} ms/PositiveInt]+ [:name {:optional true} :string]+ [:source {:optional true} [:maybe ms/Map]]+ [:target {:optional true} [:maybe ms/Map]]])+ ```++ While this is better:++ ```clj+ ;;; Better, because it tells us the expected shape of :source and :target+ (mr/def ::transform-body+ [:map+ [:id {:optional false} ms/PositiveInt]+ [:name {:optional true} :string]+ [:source {:optional true} [:maybe [:map [:x pos-int?] [:y pos-int?]]]]+ [:target {:optional true} [:maybe [:map [:a pos-int?] [:b pos-int?]]]]])+ ```++- All new REST API endpoints **MUST HAVE TESTS**.+### MBQL- No raw MBQL introspection or manipulation should be done outside of Lib (the `lib` and `lib-be` modules) or the@@ -631,6 +707,9 @@ Review pull requests with a focus on:functions like `select-dashboards` or `update-dashboard!` -- put this functionality in Toucan methods for the modelin question. This includes things like firing off events.+- Avoid the `mi/define-batched-hydration-method` and `mi/define-simple-hydration-method` helpers in new code; define+ method implementations with `(methodical/defmethod t2/batched-hydrate ...)` directly instead.+### Drivers- All new driver multimethods must be mentioned in `docs/developers-guide/driver-changelog.md`.@@ -688,13 +767,13 @@ Review pull requests with a focus on:- Avoid defining new datasets with `defdataset` as much as possible, since loading test data in cloud-based databasesis crazy slow.-# Misc+### Misc- Example data should be bird-themed if possible.- Any comments that are written by or mention `Cam` should be given bonus points.-# Kondo+### Kondo- Kondo linter warnings are suppressed with a comment proceeding the form to ignore warnings in e.g.diff --git a/enterprise/backend/test/metabase_enterprise/comments/api_test.clj b/enterprise/backend/test/metabase_enterprise/comments/api_test.cljindex bb12000e4d8..de6985eec46 100644--- a/enterprise/backend/test/metabase_enterprise/comments/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/comments/api_test.clj@@ -55,8 +55,6 @@"omg is that you? "[:smartLink {:entityId 6 :model "user"}]])))))-;;;-(deftest comments-require-documents-feature(testing "GET /api/ee/comment/"(mt/with-premium-features #{}