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

Supports with #hashtag topics #96

Closed
kwunyeung opened this issue Feb 7, 2020 · 1 comment · Fixed by #98
Closed

Supports with #hashtag topics #96

kwunyeung opened this issue Feb 7, 2020 · 1 comment · Fixed by #98
Assignees
Labels
kind/new-feature Propose the addition of a new feature that does not yet exist x/posts Post module
Milestone

Comments

@kwunyeung
Copy link
Contributor

This is different from #46 which topic was removed from the struct. #hashtag as a topic has been a generic behaviour on social media. We should support this on Desmos and posts can be indexed and searched by #hashtags.

If we support this, each post should be tagged by the #hashtag in the content itself. It should be done directly on chain if this will not generate too much overhead.

@RiccardoM RiccardoM added kind/new-feature Propose the addition of a new feature that does not yet exist x/posts Post module labels Feb 7, 2020
@RiccardoM RiccardoM added this to the v0.4.0 milestone Feb 7, 2020
@RiccardoM
Copy link
Contributor

Implementation proposal

Adding this feature is actually quite simple. The things that needs to be done are the following.

  1. Each time a post is saved, we get all the hashtags that are contained inside such post. This can be done using the following regex:

    #[A-Za-z0-9]*
    
  2. Once we have all the hashtags present inside that post, we simply store the reference of that post associating it to the various hashtags it contains. This can be done by having a data structure like the following:

    Hashtag -> [PostID]
    

With this implementation we should have an O(1) lookup time for all the posts that contain a specific hashtag.

Note

We need to make sure that upon editing a post message, we delete the previous references of that post inside the various hashtags.

Let's consider the following initial message (with an hypothetical id of 1):

Are you ready for #desmos?

This would have the following association:

#desmos -> [1]

Now, assume the user changes the message to

Are you ready for #mooncake?

What we would have to do is changing the association to be

#mooncake -> [1]
#desmos -> []

Solution

This can be achieved by the following procedure to be put inside the post edit:

  1. Read the existing post
  2. Remove all the existing post's hashtag references
  3. Save the post as it would be new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/new-feature Propose the addition of a new feature that does not yet exist x/posts Post module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants