Skip to content

Commit

Permalink
추가: 유저 like 데이터 불러오기 서비스 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahayana committed Nov 8, 2023
1 parent 2a0d629 commit 87cdbea
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions apps/friend/services/friend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from apps.friend import constants
from apps.friend.helpers import W2V
from apps.friend.models import Friend, FriendRequest
from apps.search.models import Book, News, Shopping, Youtube


class FriendService:
Expand Down Expand Up @@ -165,3 +166,33 @@ def friend_like_recommend(cls, target_user_id: int) -> List[str]:
recommend_keywords.append("찜 없음")

return recommend_keywords

@classmethod
def get_user_like_data(cls, user_id: int):

like_sentence = []
sentence = ""
limit = slice(stop=10, step=1)
youtube = Youtube.objects.filter(user_id=user_id)
news = News.objects.filter(user_id=user_id)
book = Book.objects.filter(user_id=user_id)
shopping = Shopping.objects.filter(user_id=user_id)

if youtube.exists():
for y in youtube[limit]:
sentence = sentence + y.title + " "
if news.exists():
for n in news[limit]:
sentence = sentence + n.title + " "

if book.exists():
for b in book[limit]:
sentence = sentence + b.title + " "

if shopping.exists():
for s in shopping[limit]:
sentence = sentence + s.title + " "

like_sentence.append(sentence)

return like_sentence

0 comments on commit 87cdbea

Please sign in to comment.