lodash#upperCase TypeScript Examples

The following examples show how to use lodash#upperCase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: datasource.controller.ts    From EDA with GNU Affero General Public License v3.0 6 votes vote down vote up
static async GetDataSourcesNames(req: Request, res: Response, next: NextFunction) {
        let options:QueryOptions = {};
        DataSource.find({}, '_id ds.metadata.model_name ds.security', options, (err, ds) => {
            if (!ds) {
                return next(new HttpException(500, 'Error loading DataSources'));
            }

            const names = JSON.parse(JSON.stringify(ds));

            const output = [];

            for (let i = 0, n = names.length; i < n; i += 1) {
                const e = names[i];
                output.push({ _id: e._id, model_name: e.ds.metadata.model_name });
            }
            output.sort((a,b) => (upperCase(a.model_name) > upperCase(b.model_name)) ? 1 : 
            ((upperCase(b.model_name) > upperCase(a.model_name)) ? -1 : 0))
            return res.status(200).json({ ok: true, ds: output });
        });
    }
Example #2
Source File: Arbitrageur.ts    From sakeperp-arbitrageur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private async openCEXPosition(marketId: string, leverage: Big, positionSizeAbs: Big, side: Side, open: boolean): Promise<void> {
        const release = await this.nonceMutex.acquire()
        const nowTime = Date.now()
        if (nowTime - this.openCEXPositionTime[marketId] < 4000){
            this.log.jinfo({
                event: "OpenCEXPositionTime",
                params: {
                    marketId: marketId,
                    openCEXPositionTime: this.openCEXPositionTime,
                    nowTime: nowTime
                }
            })
            release()
            return
        }
        this.openCEXPositionTime[marketId] = nowTime
        release()

        let _type = "market"
        let _side = side === Side.BUY ? "buy" : "sell"
        
        if (this.serverProfile.cexPlatform === "binance") {
            _type = upperCase(_type)
            _side = upperCase(_side)
        }

        const payload: PlaceOrderPayload = {
            market: marketId,
            side: _side,
            price: null,
            size: parseFloat(positionSizeAbs.toFixed(3)), // rounding to CEX contract decimals
            type: _type,
            leverage: leverage,
        }

        if (open) {
            this.log.jinfo({
                event: "OpenCEXPosition",
                params: payload,
            })
        }else{
            this.log.jinfo({
                event: "CloseCEXPosition",
                params: payload,
            }) 
        }
        await this.cexService.placeOrder(this.cexClient, payload)
    }
Example #3
Source File: datasource.controller.ts    From EDA with GNU Affero General Public License v3.0 5 votes vote down vote up
/* Aquesta funciĆ³ retorna els datasources disponibles per fer un dashboard.
    Un cop filtrats els permisos de grup i de usuari. */
    static async GetDataSourcesNamesForDashboard(req: Request, res: Response, next: NextFunction) {

        let options:QueryOptions = {};
        DataSource.find({}, '_id ds.metadata.model_name ds.metadata.model_granted_roles',options, (err, ds) => {
            if (!ds) {
                return next(new HttpException(500, 'Error loading DataSources'));
            }

            const names = JSON.parse(JSON.stringify(ds));

            const output = [];

            for (let i = 0, n = names.length; i < n; i += 1) {
                const e = names[i];

                if (e.ds.metadata.model_granted_roles.length > 0) {

                    const userID = req.user._id;
                    const users = [];
                    const roles = [];
                    //Get users with permission
                    e.ds.metadata.model_granted_roles.forEach(permission => {

                        switch(permission.type){
                            case 'users':
                                permission.users.forEach(user => {
                                    if (!users.includes(user)) users.push(user);
                                });
                            break;
                            case 'groups':
                                req.user.role.forEach(role => {
                                    if(permission.groups.includes(role)){
                                        if (!roles.includes(role)) roles.push(role);
                                    }
                                });
                        }
                    });

                    if (users.includes(userID) || roles.length > 0) {
                        output.push({ _id: e._id, model_name: e.ds.metadata.model_name });
                    }

                }
                else {

                    output.push({ _id: e._id, model_name: e.ds.metadata.model_name });

                }
            }
            output.sort((a,b) => (upperCase(a.model_name) > upperCase(b.model_name)) ? 1 : 
                                    ((upperCase(b.model_name) > upperCase(a.model_name)) ? -1 : 0))
            return res.status(200).json({ ok: true, ds: output });
        });
    }