Skip to content

Feature/likes and views#93

Merged
VeryBigSad merged 5 commits into
devfrom
feature/likes_and_views
Feb 24, 2023
Merged

Feature/likes and views#93
VeryBigSad merged 5 commits into
devfrom
feature/likes_and_views

Conversation

@yeezy-na-izi
Copy link
Copy Markdown
Contributor

No description provided.

Add views_count for project
Add like route and like model for project and user
Add likes counter
Copy link
Copy Markdown
Contributor

@VeryBigSad VeryBigSad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Модель LikesOnProject конечно работает, но зачем, когда можно сделать M2M поле? + штука с кешем и айпишником юзера, который посмотрел проект - тоже хотелось бы такую минимальную защиту от накрутки

Comment thread projects/models.py
Comment thread users/models.py Outdated
Comment thread users/views.py
Comment on lines +89 to +91
projects_ids_list = LikesOnProject.objects.filter(
user=self.request.user, like=True
).values_list("project", flat=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут можно сделать LikesOnProject.objects.filter(user=self.request.user, like=True).project_set.all(), нет?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я тоже так думаю)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я пробовал, не получается, мб я туплю

Comment thread projects/views.py

def retrieve(self, request, *args, **kwargs):
instance = self.get_object()
instance.increment_views_count()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я думал, что мы можем сделать так, что один айпишник может увелчить кол-во просмотров на 1 раз в 5 минут. Т.е. добавить кеш ip-project, чтобы просмотры было накрутить проще, чем просто запустить скрипт который кидает запросы к апишке

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

чтобы *сложнее было наверно)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это пока не будет делаться
Переписка с петей

Copy link
Copy Markdown
Member

@yakser yakser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

liked is liked

Comment thread projects/views.py Outdated
Comment thread projects/views.py Outdated
Comment thread projects/views.py Outdated
Comment thread users/managers.py Outdated
Comment thread users/models.py Outdated
Comment thread users/views.py Outdated
Comment thread users/models.py Outdated
Comment thread users/views.py
permission_classes = [IsAuthenticated]

def get_queryset(self):
projects_ids_list = LikesOnProject.objects.filter(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

разве тут айдишки вернутся?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да

Comment thread users/urls.py Outdated
Fix naming
Fix naming
Comment thread projects/serializers.py
def get_collaborator_count(cls, obj):
return len(obj.collaborator_set.all())

def count_likes(self, obj):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_likes_count

Comment thread users/urls.py
), # this url actually returns mentors, experts and investors
path("users/", UserList.as_view()),
path("users/projects/", UserProjectsList.as_view()),
path("users/liked/", LikedProjectList.as_view()),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users/liked_projects будет понятнее

Copy link
Copy Markdown
Contributor

@VeryBigSad VeryBigSad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

герой, все классно

@VeryBigSad VeryBigSad merged commit c569eca into dev Feb 24, 2023
@yakser yakser deleted the feature/likes_and_views branch September 8, 2023 16:09
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

Successfully merging this pull request may close these issues.

3 participants