from Matching.AbstractMatcher import AbstractMatcher
from Matching.Metrics import *


class ProjectMatcher(AbstractMatcher):
    def __init__(self, user):
        super().__init__(user)

    def get_metric(self):
        umf = self._get_umf()
        age = umf.create_age_group_metric()
        interests = umf.create_interests_metric()
        liked_back = 1.2 if umf.create_liked_back_metric() else 1
        has_matches = umf.create_has_matches_metric()
        same_projects = SameProjectMetric(self.user)
        same_project = (same_projects * 20 + (age + interests)) * (has_matches * liked_back)
        return same_project

    def query_users(self):
        user_projects = self.user.personal_information.projects
        possible_matches = []
        # filter here already to make the list smaller faster
        [possible_matches.append(user) for project in user_projects for user in project.attendees
         if self._is_matchable(user) and user not in possible_matches]
        return possible_matches
