<commit_before>package sculture.dao;

import org.springframework.stereotype.Repository;
import sculture.models.tables.Story;
import sculture.models.tables.relations.FollowUser;
import sculture.models.tables.relations.VoteStory;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;
import java.util.List;

@Repository
@Transactional
public class FollowUserDao {
    public void follow_user(long follower_id, long followed_id, boolean is_follow) {
        FollowUser followUser = new FollowUser();
        followUser.setIs_follow(is_follow);
        followUser.setFollowed_id(followed_id);
        followUser.setFollower_id(follower_id);
        entityManager.merge(followUser);
    }

    public FollowUser get(long follower_id, long followed_id) {
        Query queryVote = entityManager.createQuery("from FollowUser where follower_id = :follower_id AND followed_id = :followed_id");
        queryVote.setParameter("follower_id", follower_id);
        queryVote.setParameter("followed_id", followed_id);

        FollowUser followUser;

        try {
            followUser = (FollowUser) queryVote.getSingleResult();
        } catch (NoResultException e) {
            followUser = new FollowUser();<commit_msg>[REST] Fix followed user recommendation<commit_after>package sculture.dao;

import org.springframework.stereotype.Repository;
import sculture.models.tables.Story;
import sculture.models.tables.relations.FollowUser;
import sculture.models.tables.relations.VoteStory;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;
import java.util.List;

@Repository
@Transactional
public class FollowUserDao {
    public void follow_user(long follower_id, long followed_id, boolean is_follow) {
        FollowUser followUser = new FollowUser();
        followUser.setIs_follow(is_follow);
        followUser.setFollowed_id(followed_id);
        followUser.setFollower_id(follower_id);
        entityManager.merge(followUser);
    }

    public FollowUser get(long follower_id, long followed_id) {
        Query queryVote = entityManager.createQuery("from FollowUser where follower_id = :follower_id AND followed_id = :followed_id AND is_follow = true");
        queryVote.setParameter("follower_id", follower_id);
        queryVote.setParameter("followed_id", followed_id);

        FollowUser followUser;

        try {
            followUser = (FollowUser) queryVote.getSingleResult();
        } catch (NoResultException e) {
            followUser = new FollowUser();
{'fraction_non_alphanumeric': 0.08486818345973275, 'fraction_numerical': 0.0, 'mean_word_length': 4.3996101364522415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3520250', 'n_tokens_mistral': 792, 'n_tokens_neox': 763, 'n_words': 156}