Skip to content

Conversation

@EugeneChung
Copy link
Contributor

Summary

Adds a "View in GitHub" link in the query page dropdown menu that links to synced SQL files in the dna_redash_queries repository (https://github.com/teamdable/dna_redash_queries).

Changes

Backend

  • Added GitHub API configuration via environment variables
  • Created /api/queries/<query_id>/github_file_exists endpoint to verify file existence
  • Exposed GitHub config to frontend via client_config API

Frontend

  • Created useGitHubLink custom React hook with 5-minute sessionStorage cache
  • Added "View in GitHub" menu item in query page header dropdown (under "Show API Key")
  • Link opens in new tab with external link icon

Features

  • Automatically calculates correct range bucket (e.g., 10574 → 10001-11000)
  • Only displays link if file exists (verified via GitHub API)
  • Caches results for 5 minutes to reduce API calls
  • Only shows for existing queries (not new queries)

Environment Variables

REDASH_GITHUB_API_TOKEN=your_github_token_here     # Required
REDASH_GITHUB_QUERIES_REPO=teamdable/dna_redash_queries  # Default
REDASH_GITHUB_QUERIES_BRANCH=main                  # Default

Test Plan

  • Query with synced file shows "View in GitHub" link
  • Query without synced file hides link
  • New queries hide link
  • Link opens correct GitHub URL in new tab
  • Manual testing on staging environment

🤖 Generated with Claude Code

This adds a "View in GitHub" link in the query page dropdown menu
that links to the synced SQL file in the dna_redash_queries repository.

Changes:
- Add GitHub API configuration (token, repo, branch) via environment variables
- Create API endpoint to check file existence via GitHub API
- Add custom React hook (useGitHubLink) with 5-minute cache
- Add "View in GitHub" menu item in query page header dropdown

The link appears under "Show API Key" and only displays if:
- GitHub API token is configured
- Query file exists in the repository
- Query has been saved (not new)

Environment variables:
- REDASH_GITHUB_API_TOKEN: GitHub API token (required)
- REDASH_GITHUB_QUERIES_REPO: Repository (default: teamdable/dna_redash_queries)
- REDASH_GITHUB_QUERIES_BRANCH: Branch (default: main)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@EugeneChung EugeneChung changed the title Add GitHub query link feature to query source page DP-2193 redash source 화면에서 Github link menu 를 표시한다. Nov 11, 2025
@EugeneChung EugeneChung self-assigned this Nov 11, 2025
@EugeneChung EugeneChung marked this pull request as draft January 25, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants