Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors user data queries #98

Merged
merged 79 commits into from
Sep 11, 2024
Merged

Conversation

xwilson03
Copy link
Collaborator

@xwilson03 xwilson03 commented Aug 16, 2024

Description:

Replaces heavily duplicated user data queries with functions that return new standard user interface types.

Closes #96
Depends on #77

Reviewers:

Review Guide:

db/types.ts:

  • Should interfaces other than Hacker include their relations?

    • Notable: Scan.user, Scan.event, potentially User.DiscordVerification
  • Should redundant fields be removed from interfaces with relations?

    • e.g., either Hacker.teamID or Hacker.team.id would be removed.
    • Prevents interface compatibility with raw queries
  • Clerk exports a User interface as well; is this an issue?

    • Research interface redeclaration behavior when importing from different modules
    • If problematic, could be avoided by prefixing all HackKit interfaces (User, Hacker, Event, Scan, Team)
      • hkUser, HKUser, or other ideas

db/functions/:

  • Does the current spread of functions cover enough functionality, or are there expected behaviors missing?
    • See point 2 of above (redundant field removal)
  • Should simple lookup functions be made for non- User or Hacker types? i.e., Scan, Event, and Team

Changelog:

  • Adds db/types.ts to house database-specific types

    • Converts existing db types to interfaces for cleaner IntelliSense (User, Event, Scan)
    • Renames UserWithAllData to Hacker and makes team property optional
    • Replaces InferModel calls with new interfaces across codebase
  • Adds db/functions folder to house common queries and reduce code duplication

    • User + Hacker: get(*), get(*)ByTag, getAll(*)s
    • Hacker: functions include withTeam flag for optional data inclusion
  • Replaces raw queries with functions where possible

    • Refactors transactions in scanner and check-in

package.json Show resolved Hide resolved
packages/db/functions/user.ts Show resolved Hide resolved
packages/db/functions/index.ts Show resolved Hide resolved
packages/db/functions/hacker.ts Show resolved Hide resolved
@christianhelp
Copy link
Collaborator

For future reference and reviewer sanity, it might be nice to point this PR to the sister PR #77 and then point it back to dev afterwards just so we don't have to go through a lot of the same files bc 58 files is a lot.

christianhelp
christianhelp previously approved these changes Sep 10, 2024
christianhelp
christianhelp previously approved these changes Sep 11, 2024
@christianhelp christianhelp merged commit da3ad9d into dev Sep 11, 2024
3 checks passed
@christianhelp christianhelp deleted the chore/adds-user-query-functions branch September 16, 2024 18:06
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.

Add User Functions/Interfaces
3 participants