Пример #1
0
    def __init__(self,
                 expert_language,
                 second_language,
                 expert_loc=10000,
                 second_loc=1000):
        """
        :param expert_language: helper.language.Language object of the expert language.
        :param second_language: helper.language.Language object of the language to examine. For now just Python.
        :param expert_loc: Lines of code that is the threshold for an expert.
        :param second_loc: Lines of code threshold for the language to examine to get a code base that is large enough.
        """
        self.expert_language = expert_language
        self.second_language = second_language
        self.expert_loc = expert_loc
        self.second_loc = second_loc

        settings = Settings()
        loc_user_file_ext_view = settings.get_database_view(
            'loc_user_file_ext')

        self.query = SQL('''
            SELECT
                u1.user_id,
                u1.login
            FROM {} AS u1
                JOIN {} AS u2 ON u1.user_id = u2.user_id
                JOIN users u ON u1.user_id = u.id
            WHERE u1.additions >= %s AND u1.file_ext = ANY(%s) AND u2.additions >= %s AND u2.file_ext = ANY(%s) AND u.type = 'USR';
        ''').format(Identifier(loc_user_file_ext_view),
                    Identifier(loc_user_file_ext_view))

        self.detection_path = settings.get_path([
            'detections',
            expert_language.language + '_' + second_language.language
        ])
    def __init__(self, sha):
        self.sha = sha

        settings = Settings()
        self._downloads_path = settings.get_path('downloads')
        self._download_archive_path = settings.get_path('download_archive')
        self._earliest_project_view = settings.get_database_view(
            'earliest_project')
Пример #3
0
    def __init__(self,
                 user_id,
                 login,
                 expert_language,
                 second_language,
                 expert_loc=10000,
                 second_loc=1000):
        """
        :param user_id: User id
        :param login: User name
        :param expert_language: helper.language.Language object of the expert language.
        :param second_language: helper.language.Language object of the language to examine. For now just Python.
        :param expert_loc: Lines of code that is the threshold for an expert.
        :param second_loc: Lines of code threshold for the language to examine to get a code base that is large enough.
        """
        self.user_id = user_id
        self.login = login
        self.expert_language = expert_language
        self.second_language = second_language
        self.expert_loc = expert_loc
        self.second_loc = second_loc

        settings = Settings()
        if self.expert_language.language == 'java' and self.second_language.language == 'python':
            self.candidates_view = settings.get_database_view(
                'candidates_java_py')
            self.result_dir_path = settings.get_path(
                ['detections', 'java_python'])
        elif self.expert_language.language == 'cpp' and self.second_language.language == 'python':
            self.candidates_view = settings.get_database_view(
                'candidates_cpp_py')
            self.result_dir_path = settings.get_path(
                ['detections', 'cpp_python'])
        elif self.expert_language.language == 'fun' and self.second_language.language == 'python':
            self.candidates_view = settings.get_database_view(
                'candidates_fun_py')
            self.result_dir_path = settings.get_path(
                ['detections', 'fun_python'])
        else:
            raise ValueError(
                'No database view for this combination of languages.')