Repository: Pythagora-io/gpt-pilot
File: pilot/helpers/Project.py (Python)

Code before:
        return fpath

    def get_all_database_files(self) -> list[File]:
        """
        Get all project files from the database.
        """
        return (
            File
            .select()
            .where(
                (File.app_id == self.args['app_id']) &
                peewee.fn.EXISTS(FileSnapshot.select().where(FileSnapshot.file_id == File.id))
            )
        )

    def get_all_coded_files(self, relevant_files=None):
        """
        Get all coded files in the project.

        Returns:
            list: A list of coded files.
        """
        files = self.get_all_database_files()
        if relevant_files:
            n_files0 = len(files)
            files = [file for file in files if self.relpath(file) in relevant_files]
            n_files1 = len(files)
            rel_txt = ",".join(relevant_files) if relevant_files else "(none)"
            logger.debug(f"[get_all_coded_files] reduced context from {n_files0} to {n_files1} files, using: {rel_txt}")

        return self.get_files([file.path + '/' + file.name for file in files])

    def get_file_summaries(self) -> Optional[dict[str, str]]:
        """
        Get summaries of all coded files in the project.

        :returns: A dictionary of file summaries, or None if file filtering is not enabled.
        """
        if os.getenv('FILTER_RELEVANT_FILES', '').lower().strip() not in ['true', '1', 'yes', 'on']:
            return None

        files = self.get_all_database_files()
        return {self.relpath(file): file.description or "(unknown)" for file in files}

    def get_files(self, files):
        """
        Get file contents.

        Args:
            files (list): List of file paths.


Review comment (suggestion):
This is the actual filtering step. The path normalization (`self.relpath`) is there so we can match file path properly with the relevant files set.

Code after:
        return fpath

    def get_all_database_files(self) -> list[File]:
        """
        Get all project files from the database.
        """
        return (
            File
            .select()
            .where(
                (File.app_id == self.args['app_id']) &
                peewee.fn.EXISTS(FileSnapshot.select().where(FileSnapshot.file_id == File.id))
            )
        )

    def get_all_coded_files(self, relevant_files=None):
        """
        Get all coded files in the project.

        Returns:
            list: A list of coded files.
        """
        files = self.get_all_database_files()
        if relevant_files:
            n_files0 = len(files)
            files = [file for file in files if self.relpath(file) in relevant_files]
            n_files1 = len(files)
            rel_txt = ",".join(relevant_files) if relevant_files else "(none)"
            logger.debug(f"[get_all_coded_files] reduced context from {n_files0} to {n_files1} files, using: {rel_txt}")

        return self.get_files([file.path + '/' + file.name for file in files])

    def get_file_summaries(self) -> Optional[dict[str, str]]:
        """
        Get summaries of all coded files in the project.

        :returns: A dictionary of file summaries, or None if file filtering is not enabled.
        """
        if os.getenv('FILTER_RELEVANT_FILES', '').lower().strip() in ['false', '0', 'no', 'off']:
            return None

        files = self.get_all_database_files()
        return {self.relpath(file): file.description or "(unknown)" for file in files if os.path.exists(file.full_path)}

    def get_files(self, files):
        """
        Get file contents.

        Args:
            files (list): List of file paths.