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

[Chore/Backend]: Reorganize user data in database #24

Open
12 tasks
miku4k opened this issue Dec 21, 2024 · 2 comments
Open
12 tasks

[Chore/Backend]: Reorganize user data in database #24

miku4k opened this issue Dec 21, 2024 · 2 comments

Comments

@miku4k
Copy link
Contributor

miku4k commented Dec 21, 2024

Changes

There are a lot of changes, and I doubt all of them can be implemented easily. I think it's best we do this slowly and when there isn't anything better to do. This is important, but not of high priority.

The layout is based on what exists in my own user data, some keys might be missing.

This is my proposed new layout

# Already stored alright, just a bit cleaner imo.
achievements:
  exp: int
  unlocked:
    [achievement name]: date
blocked: array of uid
clientSettings:
  autoplayVideos: bool
  fontSize: "normal" | "large"
  showNsfw: "Hide" | "Blur" | "Show"
  showPolitics: "Hide" | "Blur" | "Show"
  showPrideFlag: bool
  showSensitive: "Hide" | "Blur" | "Show"
DMs:
  [dm id?]:
    isOpen: bool
    unread?: int
    with: uid
email: string
# move customThemeExperiment and directMessagesExperiment here
experiments:
  [experiment name]: bool
# followers/following count is just the `.length` field on the respective arrays
followers: array of uid
following: array of uid
lastLogin: timestamp
# renamed from posts
# I don't really like this, but I don't know how to change it without losing functionality
notes:
  [note id]:
    isRenote: bool
notifications:
  unread: int
  [notification id]:
    type: notification type
    [additional fields based on type]
# can be removed once it's done, instead of staying "finished" forever
preRegisterStep: "finished" | (unknown other variants)
profileSettings:
  banner: filename
  bio: string
  display: string
  pfp: filename
  pronouns: string
# replaces readUpdates, same thing but more clearly named for its new purpose
readAnnouncements:
  [announcement name]: bool
# this looks a bit useless here, but I promise it's not
specialFlags:
  activeContributor: bool
  isSubscribed: bool
themes:
  current: builtin theme name | "Custom"
  installed: array of theme id
  colors:
    [theme fields]
  saved:
    [theme name]:
      published?: theme id
      [theme fields]
username: string

Note: Firebase automatically converts between arrays and array-like objects internally, so we can use them in some places.

Proposed Guidelines

So we don't get another mess.

  • Boolean values that mark the user as something (e.g. subscribed, verified, admin, etc.) should go under specialFlags.
  • Multiple values that relate to the same thing should be grouped together.
    userSettings and clientSettings are both settings, but don't relate to the same thing, hence aren't grouped together.
  • Temporary values (e.g. the current registration step) should be removed once they aren't needed anymore.
  • Objects where order isn't relevant should be replaced with arrays. Arrays of objects should be avoided, though.
  • Keys should follow camelCase.
  • Values outside another object aren't forbidden, but should be avoided.

Motivation

This is the current layout for user data

achievements:
  # what does this do?
  exp: int
  transsocial:
    [achievement name]:
      unlocked: bool
      unlockedWhen: date
activeContributor: bool
autoplayVideos: bool
banner: filename
bio: string
blocked:
  [user id]:
    user: uid
customThemeExperiment: bool
directMessagesExperiment: bool
display: string
email: string
experiments:
  [experiment name]: bool
followers: int
following: int
followingWho:
  [user id]:
    uid: uid
fontSizePref: "normal" | "large"
hasDMsWith:
  [user id]:
    true: bool
installedThemes:
  [theme id]:
    installed: bool
isSubscribed: bool
last_login: timestamp
notifications:
  unread: int
  [notification id]:
    type: notification type
    [additional fields based on type]
openDMs:
  [dm id?]:
    isOpen: bool
    unread?: int
pfp: filename
posts:
  [note id]:
    isRenote: bool
preRegister_Step: "finished" | (unknown other variants)
pronouns: string
readUpdates:
  [version]:
    read: bool
readnewUpdateLog: bool
readprealphaUpdateLog: bool
readv[version number]UpdateLog: bool
savedThemes:
  [theme name]:
    published?: theme id
    [theme fields]
showNsfw: "Hide" | "Blur" | "Show"
showPolitics: "Hide" | "Blur" | "Show"
# why isnt this a bool omg
showPrideFlag: "No" | "Yes"
showSensitive: "Hide" | "Blur" | "Show"
theme: builtin theme name | "Custom"
themeColors:
  [theme fields]
username: string
whoFollows:
  [user id]:
    uid: uid

It's a mess I dont like to work with.

Progress

  • Followers
  • Following
  • Blocked
  • Themes
    • Current Theme
    • Installed Themes
    • Saved Themes
    • Theme Colors
  • Client Settings
  • Profile Settings
  • Flags
  • Achievements
  • DMs
@miku4k
Copy link
Contributor Author

miku4k commented Dec 21, 2024

I would do a similar proposal for notes too, but I don't have another 3 hours.

@katniny
Copy link
Owner

katniny commented Dec 22, 2024

I can try when I feel the motivation to do so, but right now there's higher things on my priority list then how data is sorted, for now anyways.
Need to move a shit ton of code to the backend, re-add DMs, fix broken code/CSS... realistically what I'm working on right now isn't super high priority either but :p I realistically should have this done in a couple hours (not counting time toward bug fixing and testing)

Also, since there's a comment that asks:
EXP was originally going to be for a leveling system, but it didn't make sense for a social media, so I scrapped it but never removed the part that grants you the EXP.

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

No branches or pull requests

2 participants