Skip to content

Conversation

@AtelyPham
Copy link
Member

Script to backup leaderboard data from GraphQL (mainnet + testnet).

  • scripts/dumpLeaderboardData.mjs - fetches all accounts + indexing progress
  • Outputs to __fixtures__/leaderboard/ with ISO timestamp
  • Includes retry logic for flaky server

🤖 Generated with Claude Code

AtelyPham and others added 2 commits December 11, 2025 03:06
- fetch all leaderboard + indexing progress from GraphQL
- support both mainnet and testnet endpoints
- paginated fetching with retry logic (3 attempts)
- output to __fixtures__/leaderboard/ with ISO timestamp

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for tangle-leaderboard ready!

Name Link
🔨 Latest commit aade122
🔍 Latest deploy log https://app.netlify.com/projects/tangle-leaderboard/deploys/6939dab11eac8e0008957ab3
😎 Deploy Preview https://deploy-preview-3076--tangle-leaderboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit aade122
🔍 Latest deploy log https://app.netlify.com/projects/tangle-dapp/deploys/6939dab13cb85a00089d8960
😎 Deploy Preview https://deploy-preview-3076--tangle-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@claude
Copy link

claude bot commented Dec 10, 2025

Claude finished @AtelyPham's task —— View job


PR Review: Leaderboard Data Dump Script

I've completed my review of the leaderboard data dump script. Overall, this is a well-structured utility script with good error handling and retry logic. Here's my detailed feedback:

Code Quality & Best Practices

Positive aspects:

  • Clean, readable code structure with proper separation of concerns
  • Good use of ES modules and modern JavaScript features
  • Comprehensive GraphQL query with all necessary leaderboard fields
  • Proper pagination handling for large datasets
  • Clear console logging for monitoring progress

Suggestions for improvement:

  • Consider moving hardcoded values to a configuration object or environment variables:
    // scripts/dumpLeaderboardData.mjs:159
    const PAGE_SIZE = 20; // Could be configurable
  • The blockNumberSevenDaysAgo = 0 on line 165 seems intentional but lacks documentation explaining why 0 is used for "all historical data"

🐛 Potential Issues

Minor issues found:

  1. Memory usage concern: The script accumulates all accounts in memory (allNodes = [...allNodes, ...nodes] on line 186). For very large datasets, this could cause memory issues. Consider streaming to file if the dataset grows significantly.

  2. Hardcoded team accounts: The TEAM_ACCOUNTS array (lines 19-25) is hardcoded in the script. Consider moving this to a config file for easier maintenance.

  3. Error context: While retry logic is good, the error messages could provide more context about which network/operation failed.

🔒 Security Considerations

Good security practices:

  • Uses HTTPS endpoints
  • No hardcoded credentials or sensitive data
  • Proper error handling prevents information leakage

No security concerns identified - this is a read-only data fetching script with no user input or dynamic queries.

Performance Considerations

Current approach:

  • Page size of 20 is reasonable for API rate limiting
  • Exponential backoff retry strategy (2s, 4s, 6s) is appropriate
  • Sequential processing of mainnet/testnet is simple and reliable

Potential optimizations:

  • Could fetch mainnet and testnet in parallel to reduce total execution time:
    // Instead of sequential, could use Promise.all for parallel execution
    const [testnetResults, mainnetResults] = await Promise.all([
      fetchTestnetData(),
      fetchMainnetData()
    ]);

📚 Documentation & Maintenance

Good:

  • Clear file header documentation
  • Descriptive function names and variable names
  • Good console output for debugging

Suggestions:

  • Consider adding JSDoc comments for the main functions
  • The script filename could include version or date for better organization
  • Add a README section or comment explaining when/why to run this script

🧪 Testing Considerations

Current state: No tests, which is acceptable for a utility script.

If tests were desired:

  • Mock the GraphQL endpoints for unit testing
  • Test pagination logic with various response sizes
  • Test retry logic with simulated failures

Fixture Files Review

The generated fixture files look appropriate:

  • testnet-indexing-progress.json: Clean metadata structure
  • testnet-leaderboard.json: Rich account data with proper nesting
  • File naming with ISO timestamps is good for tracking

Overall Assessment

This is a solid utility script that accomplishes its goals effectively. The code is clean, handles errors appropriately, and generates useful test fixtures. The few suggestions above are minor improvements rather than critical issues.

Recommendation:Approve - Ready to merge with optional improvements for future iterations.

Todo List:

  • Read and analyze the main script file
  • Review fixture files and data structure
  • Check code quality and best practices
  • Identify potential bugs or security issues
  • Assess performance considerations
  • Provide constructive feedback

@AtelyPham AtelyPham self-assigned this Dec 10, 2025
@AtelyPham AtelyPham marked this pull request as draft December 10, 2025 20:11
@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for tangle-cloud ready!

Name Link
🔨 Latest commit aade122
🔍 Latest deploy log https://app.netlify.com/projects/tangle-cloud/deploys/6939dab11eac8e0008957aaf
😎 Deploy Preview https://deploy-preview-3076--tangle-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-project-automation github-project-automation bot moved this to Not Started 🕧 in Tangle Universe Dec 10, 2025
@AtelyPham AtelyPham moved this from Not Started 🕧 to Building 🏗️ in Tangle Universe Dec 10, 2025
Supports -y/--yes for non-interactive environments

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@AtelyPham
Copy link
Member Author

Mainnet data not included - GraphQL server (mainnet-gql.tangle.tools) is unstable. PostgreSQL connection pool terminates unexpectedly during paginated accounts query.

Error:

Connection terminated unexpectedly
pg-pool/index.js:45:11 -> PgAllRows.js:143:30

Script has retry logic (3 attempts, exponential backoff) and reduced page size (20), but server still fails. Testnet data included as proof of concept.

@AtelyPham AtelyPham marked this pull request as ready for review December 10, 2025 20:35
@claude
Copy link

claude bot commented Dec 10, 2025

Claude finished @AtelyPham's task —— View job


PR Review: Leaderboard Data Dump Script

I've completed my review of the leaderboard data dump script. Overall, this is a well-structured utility script with good error handling and retry logic. Here's my detailed feedback:

Code Quality & Best Practices

Positive aspects:

  • Clean, readable code structure with proper separation of concerns
  • Good use of ES modules and modern JavaScript features
  • Comprehensive GraphQL query with all necessary leaderboard fields
  • Proper pagination handling for large datasets
  • Clear console logging for monitoring progress

Suggestions for improvement:

  • Consider moving hardcoded values to a configuration object or environment variables:
    // scripts/dumpLeaderboardData.mjs:159
    const PAGE_SIZE = 20; // Could be configurable
  • The blockNumberSevenDaysAgo = 0 on line 165 seems intentional but lacks documentation explaining why 0 is used for "all historical data"

🐛 Potential Issues

Minor issues found:

  1. Memory usage concern: The script accumulates all accounts in memory (allNodes = [...allNodes, ...nodes] on line 186). For very large datasets, this could cause memory issues. Consider streaming to file if the dataset grows significantly.

  2. Hardcoded team accounts: The TEAM_ACCOUNTS array (lines 19-25) is hardcoded in the script. Consider moving this to a config file for easier maintenance.

  3. Error context: While retry logic is good, the error messages could provide more context about which network/operation failed.

🔒 Security Considerations

Good security practices:

  • Uses HTTPS endpoints
  • No hardcoded credentials or sensitive data
  • Proper error handling prevents information leakage

No security concerns identified - this is a read-only data fetching script with no user input or dynamic queries.

Performance Considerations

Current approach:

  • Page size of 20 is reasonable for API rate limiting
  • Exponential backoff retry strategy (2s, 4s, 6s) is appropriate
  • Sequential processing of mainnet/testnet is simple and reliable

Potential optimizations:

  • Could fetch mainnet and testnet in parallel to reduce total execution time:
    // Instead of sequential, could use Promise.all for parallel execution
    const [testnetResults, mainnetResults] = await Promise.all([
      fetchTestnetData(),
      fetchMainnetData()
    ]);

📚 Documentation & Maintenance

Good:

  • Clear file header documentation
  • Descriptive function names and variable names
  • Good console output for debugging

Suggestions:

  • Consider adding JSDoc comments for the main functions
  • The script filename could include version or date for better organization
  • Add a README section or comment explaining when/why to run this script

🧪 Testing Considerations

Current state: No tests, which is acceptable for a utility script.

If tests were desired:

  • Mock the GraphQL endpoints for unit testing
  • Test pagination logic with various response sizes
  • Test retry logic with simulated failures

Fixture Files Review

The generated fixture files look appropriate:

  • testnet-indexing-progress.json: Clean metadata structure
  • testnet-leaderboard.json: Rich account data with proper nesting
  • File naming with ISO timestamps is good for tracking

Overall Assessment

This is a solid utility script that accomplishes its goals effectively. The code is clean, handles errors appropriately, and generates useful test fixtures. The few suggestions above are minor improvements rather than critical issues.

Recommendation:Approve - Ready to merge with optional improvements for future iterations.

Todo List:

  • Read and analyze the main script file
  • Review fixture files and data structure
  • Check code quality and best practices
  • Identify potential bugs or security issues
  • Assess performance considerations
  • Provide constructive feedback

@drewstone drewstone closed this Dec 11, 2025
@github-project-automation github-project-automation bot moved this from Building 🏗️ to Completed ✅ in Tangle Universe Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed ✅

Development

Successfully merging this pull request may close these issues.

3 participants