<commit_before>"use strict";

(function () {
    angular
        .module("argo")
        .factory("streamService", streamService);

    streamService.$inject = ["$http", "$timeout", "ngSocket",
                        "quotesService", "activityService",
                        "tradesService", "ordersService", "accountsService"];
    function streamService($http, $timeout, ngSocket,
                        quotesService, activityService,
                        tradesService, ordersService, accountsService) {
        var service = {
            startStream: startStream
        };

        return service;

        function startStream(data) {
            $http.post("/api/startstream", {
                environment: data.environment,
                accessToken: data.token,
                accountId: data.accountId,
                instruments: data.instruments
            }).success(function () {
                getStream();
            });
        }

        function getStream() {
            var ws = ngSocket("ws://localhost:8000/stream");

            ws.onMessage(function (event) {
                var data,
                    tick,
                    transaction;

                try {
                    data = angular.fromJson(event.data);
                    tick = data.tick;
                    transaction = data.transaction;
                    if (tick) {
                        quotesService.updateTick(tick);
                        tradesService.updateTrades(tick);
                        ordersService.updateOrders(tick);
                    }
                    if (transaction) {
                        activityService.addActivity(transaction);

                        $timeout(function () {
                            tradesService.refresh();
                            $timeout(function () {
                                ordersService.refresh();
                                $timeout(function () {
                                    accountsService.refresh();
                                }, 100);
                            }, 100);
                        }, 100);
                    }<commit_msg>Fix timeout to refresh views.<commit_after>"use strict";

(function () {
    angular
        .module("argo")
        .factory("streamService", streamService);

    streamService.$inject = ["$http", "$timeout", "ngSocket",
                        "quotesService", "activityService",
                        "tradesService", "ordersService", "accountsService"];
    function streamService($http, $timeout, ngSocket,
                        quotesService, activityService,
                        tradesService, ordersService, accountsService) {
        var service = {
            startStream: startStream
        };

        return service;

        function startStream(data) {
            $http.post("/api/startstream", {
                environment: data.environment,
                accessToken: data.token,
                accountId: data.accountId,
                instruments: data.instruments
            }).success(function () {
                getStream();
            });
        }

        function getStream() {
            var ws = ngSocket("ws://localhost:8000/stream");

            ws.onMessage(function (event) {
                var data,
                    tick,
                    transaction;

                try {
                    data = angular.fromJson(event.data);
                    tick = data.tick;
                    transaction = data.transaction;
                    if (tick) {
                        quotesService.updateTick(tick);
                        tradesService.updateTrades(tick);
                        ordersService.updateOrders(tick);
                    }
                    if (transaction) {
                        activityService.addActivity(transaction);

                        $timeout(function () {
                            tradesService.refresh();
                            $timeout(function () {
                                ordersService.refresh();
                                $timeout(function () {
                                    accountsService.refresh();
                                }, 500);
                            }, 500);
                        }, 500);
                    }
{'fraction_non_alphanumeric': 0.09529303184125519, 'fraction_numerical': 0.005999077065066913, 'mean_word_length': 1.0761494252873562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '515154', 'n_tokens_mistral': 961, 'n_tokens_neox': 865, 'n_words': 162}