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

Global Tags #240

Closed
IMGROOT2 opened this issue Nov 16, 2022 · 38 comments
Closed

Global Tags #240

IMGROOT2 opened this issue Nov 16, 2022 · 38 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed page : account Account OR login
Milestone

Comments

@IMGROOT2
Copy link
Member

IMGROOT2 commented Nov 16, 2022

Vocabustudy Tags

Vocabustudy Tags are identifiers that appear everywhere, which help differentiate people from others:
image
It's really messy, lol.

Tags can be implemented as an array, where every user has a binary array ([0,1,1,0,0,0,0]). 1 means they have the tag; 0 means they don't. We add more values for the more tags we have. This is stored in Firebase.

Types of tags (can add more later):

  • Dev -> Developer of Vocabustudy. Must be in Vocabustudy-Developers Organization Team.
  • For Zero -> Co-founders only, right now. Maybe if we have people in important roles in the nonprofit, we'll give them the For Zero tag.
  • Donator -> Made a donation. For now, we'll manually update, but we can automate this later on
  • Honor -> Includes important test accounts, staff in discord, GitHub contributors, yk. A lot of people will have this role.
  • Helper -> Helpers in the Discord server. These are trustworthy people who make good sets. Only obtainable through applications sent through Discord.
  • number 1 Bugger -> Submitted the most bugs (obv Michael I think)
  • number 1 Active -> Most active person on vocabustudy (idk how to do this) (Only an normal user may get this role)
  • number 1 Set Maker -> Creator of most sets (Only an normal user may get this role)

Special Roles:

New Member -> Only given for the first 7 days of getting new role.
"Verified" Checkmark -> Given to only Siddhant, Ruhan, Omkar, and Nikhil's accounts

All of this will take a good amount of time to implement, which is why I'm setting the milestone to 2.0.0. Please let me know what modifications we should make

@IMGROOT2 IMGROOT2 added the enhancement New feature or request label Nov 16, 2022
@IMGROOT2 IMGROOT2 modified the milestones: 2.0.0, Future, 1.0.0 Nov 16, 2022
@IMGROOT2 IMGROOT2 added help wanted Extra attention is needed page : account Account OR login labels Nov 16, 2022
@IMGROOT2 IMGROOT2 self-assigned this Nov 16, 2022
@IMGROOT2 IMGROOT2 modified the milestones: 2.0.0, Future Nov 16, 2022
@ShreyanKhanna
Copy link

Cool, with this I also thought of like friends and follow buttons for users to know when their friends are making sets

@ShreyanKhanna
Copy link

ShreyanKhanna commented Nov 16, 2022

Idk if mine is a good idea but it’s there

@ShreyanKhanna
Copy link

I can also help with this if needed

@ShreyanKhanna
Copy link

Also what is the vocabustudy devoeloper team? Am
I in that?

@ShreyanKhanna
Copy link

Also what is the “verified” role mean… like that you have verified yourself via email or is it like Twitter

@grimsteel
Copy link
Member

This will be pretty hard to implement - Firebase does not offer a method for querying a specific user's roles w/o the Admin SDK

New Member -> Only given for the first 7 days of getting new role.
"Verified" Checkmark -> Given to only Siddhant, Ruhan, Omkar, and Nikhil's accounts

No to both of these - New Member is too hard to implement ("First 7 days") and Verified is redundant

@grimsteel
Copy link
Member

Instead of Custom Claims, we could make another thing in the database
Or we could do cloud storage because it will be cached for a pretty long amount of time but the SDK is wayyyyy too big

@grimsteel
Copy link
Member

I just saw this:

where every user has a binary array ([0,1,1,0,0,0,0]).

I have something even better - binary flags! (Or is that what you were thinking about?)
Let's say the number is 0110000 - that represents the same thing as the array
In decimal, that's 48 so we just store 48 in the database!

@ShreyanKhanna
Copy link

Yea but there is multiple ways to get 48

@ShreyanKhanna
Copy link

So binary is better tight

@grimsteel
Copy link
Member

Yea but there is multiple ways to get 48

No there's only one way

@ShreyanKhanna
Copy link

Oh wait

@ShreyanKhanna
Copy link

I’m selling

@ShreyanKhanna
Copy link

Nevermind

@IMGROOT2
Copy link
Member Author

I have something even better - binary flags! (Or is that what you were thinking about?) Let's say the number is 0110000 - that represents the same thing as the array In decimal, that's 48 so we just store 48 in the database!

That's genius!! perfect

@grimsteel
Copy link
Member

Thanks! So let's say 0100000 (32) means "Admin", 0010000 (16) means "Honor" and 0001000 (8) means "Helper"

Boolean(48 & 32) // true
Boolean(48 & 16) // true
Boolean(48 & 8) // false

We can probably store all of this in Cloud Storage as a JSON file (the tags won't change too often right?) with a 2-3 day cache

{
  // The bit mask is  2^index in array
  "t": [{"n": "Dev", "c": "some color"},{"n": "For Zero", "c": "some color"},{"n": "Donator", "c": "some color"},{"n": "Honor", "c": "some color"},{"n": "Helper", "c": "some color"}],
  "u": {"userid": 48, "userid2": 10}
}

Then to parse it:

const globalTags = await fetch("...");
function getTagsForUser(userId) {
  let userTags = [];
  let userTagsNum = globalTags.u[userId];
  for (let [i, tag] of globalTags.t.entries()) {
    if (userTagsNum & (1 << 5)) userTags.push(tag);
  }
  return userTags;
}

@PrakmO
Copy link
Member

PrakmO commented Nov 19, 2022

Good idea

@ShreyanKhanna
Copy link

Thanks! So let's say 0100000 (32) means "Admin", 0010000 (16) means "Honor" and 0001000 (8) means "Helper"

Boolean(48 & 32) // true
Boolean(48 & 16) // true
Boolean(48 & 8) // false

We can probably store all of this in Cloud Storage as a JSON file (the tags won't change too often right?) with a 2-3 day cache

{
  // The bit mask is  2^index in array
  "t": [{"n": "Dev", "c": "some color"},{"n": "For Zero", "c": "some color"},{"n": "Donator", "c": "some color"},{"n": "Honor", "c": "some color"},{"n": "Helper", "c": "some color"}],
  "u": {"userid": 48, "userid2": 10}
}

Then to parse it:

const globalTags = await fetch("...");
function getTagsForUser(userId) {
  let userTags = [];
  let userTagsNum = globalTags.u[userId];
  for (let [i, tag] of globalTags.t.entries()) {
    if (userTagsNum & (1 << 5)) userTags.push(tag);
  }
  return userTags;
}

Ok that is acc perfect… idk why ur code looks so much better than mine… but yea genius

@grimsteel
Copy link
Member

I love binary operations

@IMGROOT2
Copy link
Member Author

Your code seems great. Although, because of the number 1 tags, it will be better to use a 1 day cache so it updates every day.

@IMGROOT2
Copy link
Member Author

I love binary operations

I can see that, lol. Will the JSON file be automatically updated? does Firebase take care of that?

@grimsteel
Copy link
Member

I don't think there would be a source to automatically update from, so we would have to do it manually
Also I'm not sure if we should have the #1 tags - that encourages competition (trust me people have been telling me to bring the leaderboard back...) which I don't want

@IMGROOT2
Copy link
Member Author

firestore is a source to automatically update from, no? we assign the binary code to each uid. can we not fetch the binary number whenever we need to display tags, and then write a function to display them?

@grimsteel
Copy link
Member

There are three possible things we could do:

  1. Use Firestore and generate a JSON stored in Cloud Storage
  2. Do it all in Cloud Storage (my preferred option)
  3. Do it all in Firestore (I think this is what you are saying?)

The thing about option 3 is that it would be harder to cache than Cloud Storage. In addition, there are two possible options for that:
users collection:

ID tags <other acct preferences (#191)>
uid1 48 stuff
uid2 36 more stuff

tags collection:

ID tags
random thing because there will only be one document here {"uid1": 48, "uid2": 36}

the users collection would mean one DB read for each user (too much even w/ caching)
the tags collection is reinventing cloud storage
I can write a script to update the JSON file at our wish

@ShreyanKhanna
Copy link

Okay I think that # 2 is the best like u said bc that’s the way I have tried before… like long ago when I was helping my cousin make a website for stuff…(I just was trying to learn what he was doing)

also why did u add me to the developers and then remove me.. like it’s cool… I can be a developer Idrc rn cuz I haven’t done anything and I should but my parents want me doing other things away from my computer for thanksgiving break so I’m unable to sorry

@grimsteel
Copy link
Member

Okay I think that # 2 is the best

Thanks

also why did u add me to the developers and then remove me

I don't want to seem rude or anything but you haven't committed to the repo at all yet, and being on the developers team gives you full write access. I wanted you to have the info in the team, but I wanted to hold off on the perms for now. I added developing info to the README if you want to see that

Note that you don't have to be on the developers team to be a contributer - being on it just shows that you have a reasonable experience with the Vocabustudy code

@ShreyanKhanna
Copy link

Okay I think that # 2 is the best

Thanks

also why did u add me to the developers and then remove me

I don't want to seem rude or anything but you haven't committed to the repo at all yet, and being on the developers team gives you full write access. I wanted you to have the info in the team, but I wanted to hold off on the perms for now. I added developing info to the README if you want to see that

Note that you don't have to be on the developers team to be a contributer - being on it just shows that you have a reasonable experience with the Vocabustudy code

Makes sense cuz like u said I haven’t done anything so I only want it if I do things and I need it… plus I’m kinda brainstorming and when I’m like boom we need to do this… it just doesn’t seem good and I’m kinda scared that it is a bad idea and don’t put an issue in

@grimsteel
Copy link
Member

No worries - if you want a place to put brainstormed ideas that may not warrant a full issue, you could use discussions

@ShreyanKhanna
Copy link

Yea sound good

@IMGROOT2
Copy link
Member Author

There are three possible things we could do:

  1. Use Firestore and generate a JSON stored in Cloud Storage
  2. Do it all in Cloud Storage (my preferred option)
  3. Do it all in Firestore (I think this is what you are saying?)

The thing about option 3 is that it would be harder to cache than Cloud Storage. In addition, there are two possible options for that: users collection:

I was thinking option 3.1 lol. if you're comfortable with cloud storage, then let's do that.

@ShreyanKhanna
Copy link

There are three possible things we could do:

  1. Use Firestore and generate a JSON stored in Cloud Storage
  2. Do it all in Cloud Storage (my preferred option)
  3. Do it all in Firestore (I think this is what you are saying?)

The thing about option 3 is that it would be harder to cache than Cloud Storage. In addition, there are two possible options for that: users collection:

I was thinking option 3.1 lol. if you're comfortable with cloud storage, then let's do that.

That would also work but hear me out and I could be wrong but isn’t option 2 simpler?

@ShreyanKhanna
Copy link

And more versatile?

@IMGROOT2
Copy link
Member Author

option 2 is cloud storage lol. we're on the same page

@ShreyanKhanna
Copy link

Alr

@IMGROOT2
Copy link
Member Author

This will now be 10 times easier with Bulma tags

@PrakmO
Copy link
Member

PrakmO commented Nov 26, 2022

nice

@ShreyanKhanna
Copy link

This will now be 10 times easier with Bulma tags

perfect

@grimsteel
Copy link
Member

Handled by the custom roles auth property (#291)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed page : account Account OR login
Projects
Status: Done
Development

No branches or pull requests

4 participants