Skip to content

Admin Refresh Endpoint Not Functional #3

Open
@wtfsayo

Description

@wtfsayo

Issue ID: 005
Priority: High
Status: Open
Created: 2025-01-05
Component: API/Admin

Description

The /api/admin/refresh endpoint is currently non-functional. When called, it only returns a success message with a TODO comment stating "This would trigger a full data refresh" but doesn't actually perform any data refresh operations.

Current Behavior

When making a POST request to /api/admin/refresh:

  • Returns: { "message": "Refresh triggered", "todo": "This would trigger a full data refresh" }
  • No actual data refresh occurs
  • No wallet balances are updated
  • No token prices are refreshed

Expected Behavior

The endpoint should:

  1. Trigger the prefetch process programmatically
  2. Perform the same operations as running bun run prefetch:force
  3. Update all wallet balances from the blockchain
  4. Refresh token prices and metadata
  5. Return meaningful status information about the refresh operation

Technical Details

Current Implementation

Located in src/routes/api.ts, the endpoint handler is:

app.post('/api/admin/refresh', async (c) => {
  // TODO: Implement actual refresh logic
  return c.json({ 
    message: 'Refresh triggered',
    todo: 'This would trigger a full data refresh'
  });
});

Required Implementation

The endpoint should:

  • Import and utilize the prefetch functionality from src/scripts/prefetch.ts
  • Handle the refresh operation asynchronously
  • Provide progress tracking or status updates
  • Handle errors gracefully
  • Ensure proper rate limiting is maintained

Impact

  • Users: Cannot trigger data refreshes through the API
  • System: Must rely on manual CLI commands or scheduled tasks for data updates
  • Operations: Limits automation capabilities and real-time data management

Proposed Solution

  1. Import the prefetch logic into the API route handler
  2. Implement proper async handling for the long-running operation
  3. Consider implementing a job queue or background task system
  4. Return a job ID that can be used to check refresh status
  5. Add a companion endpoint to check refresh job status

Related Files

  • src/routes/api.ts - Contains the non-functional endpoint
  • src/scripts/prefetch.ts - Contains the working prefetch logic
  • src/services/database.ts - Database operations
  • src/services/solana.ts - Blockchain data fetching

Notes

This is a critical feature for maintaining data freshness without manual intervention. The endpoint exists but lacks implementation, which could mislead users expecting it to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions