async getAll()

in src/server/services/cla.js [637:693]


    async getAll(args) {
        if (!args.gist || !args.gist.gist_url || (!args.repoId && !args.orgId)) {
            throw new Error('Wrong arguments, gist url or repo id are missing')
        }
        let selection = {
            gist_url: args.gist.gist_url
        }
        const options = {
            sort: {
                user: 1,
                userId: 1
            }
        }
        if (args.gist.gist_version) {
            selection.gist_version = args.gist.gist_version
            options.sort = {
                'created_at': -1
            }
        }
        if (args.repoId) {
            selection.repoId = args.repoId
        }
        if (args.orgId) {
            selection.ownerId = args.orgId
        }
        selection = this._updateQuery(selection, args.sharedGist)

        if (!args.gist.gist_version) {
            try {
                return CLA.find(selection, {}, options)
            } catch (error) {
                logger.warn('Error occured when getting all signed CLAs for given repo without gist version' + error)
                logger.warn('Api cla.getAll failed with selection ' + selection)
                // eslint-disable-next-line no-console
                console.log('Api cla.getAll failed with selection from console log ' + selection)
            }
        }
        try {
            const clas = await CLA.find(selection, {}, options)
            if (!clas) {
                throw new Error('no clas found')
            }
            const foundSigners = []
            const distinctClas = clas.filter((cla) => {
                if (foundSigners.indexOf(cla.userId) < 0) {
                    foundSigners.push(cla.userId)
                    return true
                }
                return false
            })
            return distinctClas
        } catch (error) {
            logger.warn('Error occured when getting all signed CLAs for given repo ' + error)
        }


    }