<commit_before>class ProjectsListController {
    constructor( // eslint-disable-line max-params
        $log, $state, $uibModal, $scope, projectService, userService
    ) {
        'ngInject';
        this.$log = $log;
        this.$state = $state;
        this.$uibModal = $uibModal;
        this.projectService = projectService;
        this.userService = userService;
        this.$scope = $scope;

        this.projectList = [];
        this.populateProjectList($state.params.page || 1);
    }

    populateProjectList(page) {
        if (this.loading) {
            return;
        }
        delete this.errorMsg;
        this.loading = true;
        this.projectService.query(
            {
                sort: 'createdAt,desc',
                pageSize: 10,
                page: page - 1
            }
        ).then(
            (projectResult) => {
                this.lastProjectResult = projectResult;
                this.numPaginationButtons = 6 - projectResult.page % 10;
                if (this.numPaginationButtons < 3) {
                    this.numPaginationButtons = 3;
                }
                this.currentPage = projectResult.page + 1;
                let replace = !this.$state.params.page;
                this.$state.transitionTo(
                    this.$state.$current.name,
                    {page: this.currentPage},
                    {
                        location: replace ? 'replace' : true,
                        notify: false
                    }
                );
                this.projectList = this.lastProjectResult.results;
                this.loading = false;
                this.projectList.forEach((project) => {
                    this.getProjectScenesCount(project);
                });
            },
            () => {
                this.errorMsg = 'Server error.';
                this.loading = false;
            }
        );
    }

    getProjectScenesCount(project) {
        this.projectService.getProjectSceneCount({projectId: project.id}).then(
            (sceneResult) => {
                let bupdate = this.projectList.find((b) => b.id === project.id);
                bupdate.scenes = sceneResult.count;
            }
        );
    }

    viewProjectDetail(project) {
        this.$state.go('^.detail', {project: project, projectid: project.id});
    }

    createNewProject() {
        if (this.newProjectModal) {
            this.newProjectModal.dismiss();
        }

        this.newProjectModal = this.$uibModal.open({
            component: 'rfCreateProjectModal'
        });

        this.newProjectModal.result.then((data) => {
            if (data.reloadProjectList) {
                this.populateProjectList(1);
            }
        });

        return this.newProjectModal;
    }
}

export default ProjectsListController;
<commit_msg>Handle possible undefined return from project create modal (#1845)<commit_after>class ProjectsListController {
    constructor( // eslint-disable-line max-params
        $log, $state, $uibModal, $scope, projectService, userService
    ) {
        'ngInject';
        this.$log = $log;
        this.$state = $state;
        this.$uibModal = $uibModal;
        this.projectService = projectService;
        this.userService = userService;
        this.$scope = $scope;

        this.projectList = [];
        this.populateProjectList($state.params.page || 1);
    }

    populateProjectList(page) {
        if (this.loading) {
            return;
        }
        delete this.errorMsg;
        this.loading = true;
        this.projectService.query(
            {
                sort: 'createdAt,desc',
                pageSize: 10,
                page: page - 1
            }
        ).then(
            (projectResult) => {
                this.lastProjectResult = projectResult;
                this.numPaginationButtons = 6 - projectResult.page % 10;
                if (this.numPaginationButtons < 3) {
                    this.numPaginationButtons = 3;
                }
                this.currentPage = projectResult.page + 1;
                let replace = !this.$state.params.page;
                this.$state.transitionTo(
                    this.$state.$current.name,
                    {page: this.currentPage},
                    {
                        location: replace ? 'replace' : true,
                        notify: false
                    }
                );
                this.projectList = this.lastProjectResult.results;
                this.loading = false;
                this.projectList.forEach((project) => {
                    this.getProjectScenesCount(project);
                });
            },
            () => {
                this.errorMsg = 'Server error.';
                this.loading = false;
            }
        );
    }

    getProjectScenesCount(project) {
        this.projectService.getProjectSceneCount({projectId: project.id}).then(
            (sceneResult) => {
                let bupdate = this.projectList.find((b) => b.id === project.id);
                bupdate.scenes = sceneResult.count;
            }
        );
    }

    viewProjectDetail(project) {
        this.$state.go('^.detail', {project: project, projectid: project.id});
    }

    createNewProject() {
        if (this.newProjectModal) {
            this.newProjectModal.dismiss();
        }

        this.newProjectModal = this.$uibModal.open({
            component: 'rfCreateProjectModal'
        });

        this.newProjectModal.result.then((data) => {
            if (data && data.reloadProjectList) {
                this.populateProjectList(1);
            }
        });

        return this.newProjectModal;
    }
}

export default ProjectsListController;

{'fraction_non_alphanumeric': 0.11018276762402089, 'fraction_numerical': 0.004525674499564839, 'mean_word_length': 1.4193684210526316, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6200249', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1458, 'n_words': 243}