Skip to content

Cleanup props on User Schema and DB records for a User #50344

Open

Description

@raisedadead
No description provided.

Activity

  1. converted this from a draft issue on May 10, 2023
  2. locked and limited conversation to collaborators on May 10, 2023
  3. ShaunSHamilton commented on May 10, 2023

    @ShaunSHamilton
    Member

    Fields to Remove

    • github
      • Not set anymore, and not used on server/client
    • isGithub
    • isLinkedIn
    • isTwitter
    • isWebsite
    • password
    • timezone
      • Not currently used. Do we plan to?
    • verificationToken
      • Appears to be entirely related to LB
      • Not set this anywhere except to null in User.confirm which is never directly called
    • badges
      • Not currently used. Do we plan to?
    • rand
      • Do we need this?

    Transformation Strategy

    We have concluded an initial (needed) normalization will involve transforming optional array types into [].

    completedChallenges.files is an array type, but does not exist on every completed challenge. Do we want to add files: [] to every single completedChallenges element? If not, we will not be able to make use of strong typing using Prisma.

    • completedChallenges
      • remove all __<> properties
    • profileUI
      • remove all __<> properties
    • progressTimestamps
      • [{ timestamp: Double }] -> [Double]
      • [Null] -> []
      • [Int64] -> [Double]
    • partiallyCompletedChallenges
      • Undefined -> []
    • yearsTopContributor
      • Undefined -> []
      • [String] -> [Double]
        • A string of length 4 takes 24 bytes, a double takes 8 bytes
    • savedChallenges
      • Undefined -> []
    • badges
      • Undefined -> []
      • Remove?
  4. raisedadead commented on May 10, 2023

    @raisedadead
    MemberAuthor

    The is* flag seems to be present in the code, last I checked. Do you think removing has any impact?

  5. ShaunSHamilton commented on May 10, 2023

    @ShaunSHamilton
    Member

    Do you think removing has any impact?

    Thank you for making me double-check. The is<> fields are never used, but are still being set:

    User.getPublicProfile = function getPublicProfile(username, cb) {
    return User.findOne$({ where: { username } })
    .flatMap(user => {
    if (!user) {
    return Observable.of({});
    }
    const { completedChallenges, progressTimestamps, timezone, profileUI } =
    user;
    const allUser = {
    ..._.pick(user, publicUserProps),
    isGithub: !!user.githubProfile,
    isLinkedIn: !!user.linkedin,
    isTwitter: !!user.twitter,
    isWebsite: !!user.website,
    points: progressTimestamps.length,
    completedChallenges,
    ...getProgress(progressTimestamps, timezone),
    ...normaliseUserFields(user),
    joinDate: user.id.getTimestamp()
    };

    At one point, I assume they were used for logic on the client like:

    if (isGithub) {
      return <h1>{user.githubProfile}</h1>
    }

    Now, we just use:

    {githubProfile ? GithubIcon(githubProfile, username) : null}

  6. ShaunSHamilton commented on May 10, 2023

    @ShaunSHamilton
    Member

    I ran the script locally and it took ~20 minutes on 8 threads. Obviously, this is almost meaningless (being on just my machine), but it does show that this is not the type of thing to take hours/days.

    After searching through the local DB, it looks like what was meant to be done was done.

  7. raisedadead commented on May 10, 2023

    @raisedadead
    MemberAuthor

    Did you get a chance to profile the memory and CPU usage?

  8. ShaunSHamilton commented on May 10, 2023

    @ShaunSHamilton
    Member

    Did you get a chance to profile the memory and CPU usage?

    Yes, but only from a whole-system perspective - I did not see an easy way to log MongoDB-specific usage other than htop.

    Process CPU [%] Memory [GB]
    mongod 20 < x < 30 18 < x < 23 *
    script 60 < x < 70 6 < x < 8
    • 4GB of swap was used, but I do not know who ate this
  9. raisedadead commented on May 11, 2023

    @raisedadead
    MemberAuthor

    Do you have the specs for the machine you run this on? How many CPUS, total memory? We could do a comparison test on MongoDB Cloud that way.

  10. ShaunSHamilton commented on May 11, 2023

    @ShaunSHamilton
    Member

    Do you have the specs for the machine you run this on? How many CPUS, total memory?

    Yes, but I do not think it is remotely comparable. As discussed, we should go with a staging test. Then, the only thing we need to decide is what machine runs the script.

  11. naomi-lgbt commented on May 15, 2023

    @naomi-lgbt
    Member

    Then, the only thing we need to decide is what machine runs the script.

    I'd suggest spinning up a DigitalOcean droplet to run the script and destroying it once done.

  12. ShaunSHamilton commented on May 17, 2023

    @ShaunSHamilton
    Member

    The normalization script is ready (for review at least).

    Action Plan

    • Merge normalization script
    • Generate hammer script to 🔨 the API
      • Typical Camper behaviour causing reads/writes to DB
      • Match typical concurrents
      • Merge
    • Seed staging with production
      • Upgrade to match prod
    • Deploy normalization script to droplet 💧
    • Deploy hammer script possibly to same 💧
    • Run and observe
  13. added
    platform: api
    on Mar 19, 2024
  14. moT01 commented on Apr 30, 2024

    @moT01
    Member

    Could we move this to post-mvp?

  15. ojeytonwilliams commented on Apr 30, 2024

    @ojeytonwilliams
    Contributor

    It doesn't seem strictly necessary, so post-MVP seems best.

  16. ojeytonwilliams commented on Jun 12, 2024

    @ojeytonwilliams
    Contributor

    @ShaunSHamilton based on our recent discussions, I think we're likely to do this after deploying the new api. As such, I'm moving it to Post-MVP. Please move it back if I've misunderstood.

  17. ShaunSHamilton commented on Jun 12, 2024

    @ShaunSHamilton
    Member

    To prevent LB from adding back stuff we do not want, this should be Post MVP. Thanks, @ojeytonwilliams

  18. added
    status: on the roadmap
    on Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: apistatus: on the roadmap

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions