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

[Feature]: profile page #135

Closed
moonlitgrace opened this issue Jan 20, 2025 · 12 comments · Fixed by #251
Closed

[Feature]: profile page #135

moonlitgrace opened this issue Jan 20, 2025 · 12 comments · Fixed by #251
Assignees
Labels
backend Related to backend enhancement New feature or request frontend Related to frontend

Comments

@moonlitgrace
Copy link
Member

Describe the feature

profile page akin to https://www.reddit.com/user/GovernmentWaste3396/
just add only necessary features and stuff and disable others which will be implemented later.

How important is this feature?

High priority

Additional context or examples

No response

@moonlitgrace moonlitgrace added backend Related to backend enhancement New feature or request frontend Related to frontend labels Jan 20, 2025
@moonlitgrace moonlitgrace mentioned this issue Jan 20, 2025
6 tasks
@Sahal-Rasheed
Copy link
Contributor

Hi @moonlitgrace,
I am interested in working on the backend part of this feature. Could you provide more details on what needs to be handled from the backend side for this ?

@moonlitgrace
Copy link
Member Author

hey @Sahal-Rasheed,
thank you for your interest. so here is a basic sketch of what i've in mind, please take a look.

those tabs will on different endpoints,
eg:
/u/<username>/overview/ returns overview of profile (like format in sketch).
you could use annote to add new field and serialize based on that type.
and return a list of containing both, then we will render them on frontend based on type field.
("type": "comment" | "post")

like this other endpoints:
u/<username>/posts/ returns posts only (in date order).
likewise for rest.

you could use actions decorator for extra actions for profile endpoint.

and i suggest you to take a look at how reddit UI is: here
lmk if you've any doubts.

@Sahal-Rasheed
Copy link
Contributor

hey @Sahal-Rasheed, thank you for your interest. so here is a basic sketch of what i've in mind, please take a look.

those tabs will on different endpoints, eg: /u/<username>/overview/ returns overview of profile (like format in sketch). you could use annote to add new field and serialize based on that type. and return a list of containing both, then we will render them on frontend based on type field. ("type": "comment" | "post")

like this other endpoints: u/<username>/posts/ returns posts only (in date order). likewise for rest.

you could use actions decorator for extra actions for profile endpoint.

and i suggest you to take a look at how reddit UI is: here lmk if you've any doubts.

Hi @moonlitgrace,
Thanks for the explanation! I’m setting up the environment to start working on this. Do you have a database dump available to populate the DB? Also, is there a Postman collection for API testing? Let me know. If I have any further doubts, I’ll reach out. Looking forward to contributing.

@moonlitgrace
Copy link
Member Author

moonlitgrace commented Jan 31, 2025

Do you have a database dump available to populate the DB? Also, is there a Postman collection for API testing?

unfortunately, no for both. i dont have a proper db to share. and I dont use postman every time.
maybe you could help me with that :)

apart from that, could you also add a banner field to the Profile modal? same as the avatar one.
lookin forward to your contributions 🚀

@Sahal-Rasheed
Copy link
Contributor

Sahal-Rasheed commented Jan 31, 2025

hi @moonlitgrace,
for the above task you explained lil bit confused as shall we use the existing PostSerializer, CommentDetailSerializer for serializing Post, Comment or should we create a new ones ? Also for the /overview endpoint we will need the type field but for rest all that field is not needed so here is what i thought of have a look and share your thoughts on this, if any other way around we can discuss.

@moonlitgrace
Copy link
Member Author

@Sahal-Rasheed, thats a good take. do we actually need another 2 serializers?
what do you think abt something like this:

# annotate a new value to queryset
posts = <post-filter-here>.annotate(type=Value("post", CharField()))
comments = <comment-filter-here>.annotate(type=Value("comment", CharField()))

sorted_list = # [do something to sort based on "created_at" value)

serialized_data = OverviewSerializer(sorted_list, many=True).data

# OverviewSerializer
class OverviewSerializer(serializers.Serializer):
    type = serializers.CharField()
    data = serializers.SerializerMethodField()

    def get_data(self, obj):
        # remove type field from obj and pass to serializers
        if obj.type == "post":
            return PostSerializer(obj).data
        return CommentSerializer(obj).data

# do other stuffs

so the output will be like:

[{ "type": "comment", "data": ...data_here }, ...same for post type ]

@Sahal-Rasheed
Copy link
Contributor

@moonlitgrace, if the existing Post and Comment serializer is enough for serializing the Post and Comment data as per our requirement then no need to create another 2 serializers. we can simple re-use the exisiting once as u mentioned above. with that we can use the OverviewSerializer for the /overview endpoint and the existing Post and Comment serializer for the other endpoints respectively. also since this OverviewSerializer is related to both Post and Comment shall i create this as a separate serializer under /serializers/overview/. ? plz let me know u r thoughts on this.

@moonlitgrace
Copy link
Member Author

@Sahal-Rasheed since overview is not a specific app, what abt doing it like- /api/serializers/user/profile/overview.py?
this way we can do other combined serializers like- [upvoted,downvoted].py in same dir.
so yea lmk if this sounds good and pls go ahead, we'll see.

@Sahal-Rasheed
Copy link
Contributor

@moonlitgrace, I’ve opened a PR (#160) implementing overview api as discussed.
Before proceeding with the remaining APIs, I'd appreciate your feedback on this implementation to ensure alignment with project requirements. Is this what you expected ? Am attaching sample api response of overview api here.
Let me know if any changes are needed. Thanks!

@moonlitgrace
Copy link
Member Author

@Sahal-Rasheed here you go: #160 (review)

@Sahal-Rasheed
Copy link
Contributor

@moonlitgrace so ig the backend stuff related to this issue is now sorted. so any other stuff should i look in to in backend ?

@moonlitgrace
Copy link
Member Author

@Sahal-Rasheed api looks good, I'll start FE integration and will let u know if any changes are needed in backend.
appreciate ur contributions ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend enhancement New feature or request frontend Related to frontend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants