Skip to content

TODO: Implement database save in rewards.ts saveToDatabase() #296

Description

@khuepm

Summary

The saveToDatabase() helper in the landing app's rewards module is an unimplemented stub. It is exported and callable, but its body contains only a TODO comment and commented-out example code, so sponsor records are never persisted.

Exact TODO text

// TODO: Implement database save

File location

apps/landing/src/lib/rewards.ts — line 68

Permalink: https://github.com/khuepm/LumiBase/blob/main/apps/landing/src/lib/rewards.ts#L68

Surrounding code context (lines 58-86)

export function getAllSponsors() {
  return Array.from(sponsors.values());
}

// In production, replace these with database operations
export async function saveToDatabase(sponsor: {
  githubUser: string;
  tier: number;
  rewardToken: string;
}) {
  // TODO: Implement database save
  // Example with PostgreSQL:
  // await db.sponsors.create({
  //   data: {
  //     githubUser: sponsor.githubUser,
  //     tier: sponsor.tier,
  //     rewardToken: sponsor.rewardToken,
  //     createdAt: new Date(),
  //   }
  // });
}

export async function updateClaimStatus(token: string) {
  const sponsor = getSponsorByToken(token);
  if (sponsor) {
    sponsor.claimed = true;
    sponsor.claimedAt = new Date();
  }
}

Why it matters

The module stores sponsor and reward-token state in a module-level in-memory Map (line 4 notes it is "for demo purposes"). Because saveToDatabase() is a no-op, all sponsor records and reward-claim state are lost on process restart and are not shared across instances. updateClaimStatus() has the same limitation — it mutates the in-memory object rather than persisting the claim.

Suggested work

Implement real persistence for saveToDatabase(), back getSponsorByToken() / getSponsorByGitHubUser() / claimReward() / updateClaimStatus() with the same store, and make claimReward() atomic so a reward token cannot be claimed twice under concurrent requests.

Status verification

Still unresolved as of main — the function body contains no implementation, so this is not a stale comment left behind after a fix.


Filed as part of a repository-wide TODO/FIXME scan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions