<commit_before>define(['app'], function(app) {
  app.controller('buildLogDetailsCtrl', [
      '$scope', '$rootScope', 'initialBuild', 'initialBuildLog', '$window', '$timeout', '$http', '$routeParams', 'stream',
      function($scope, $rootScope, initialBuild, initialBuildLog, $window, $timeout, $http, $routeParams, Stream) {
    'use strict';

    var stream, logChunkData = {
          text: '',
          size: 0,
          nextOffset: 0
        },
        entrypoint = '/api/0/builds/' + $routeParams.build_id + '/logs/' + $routeParams.source_id + '/';

    function updateBuildLog(data) {
      var $el = $('#log-' + data.source.id + ' > .build-log'),
          source_id = data.source.id,
          chars_to_remove, lines_to_remove,
          buffer_size = 100000;

      if (data.offset < logChunkData.nextOffset) {
        return;
      }

      console.log('[Build Log] Got chunk ' + data.id + ' (offset ' + data.offset + ')');

      logChunkData.nextOffset = data.offset + data.size;

      if (logChunkData.size > buffer_size) {
        $el.empty();
      } else {
        // determine how much space we need to clear up to append data.size
        chars_to_remove = 0 - (buffer_size - logChunkData.size - data.size);

        if (chars_to_remove > 0) {
          // determine the number of actual lines to remove
          lines_to_remove = logChunkData.text.substr(0, chars_to_remove).split('\n').length;

          // remove number of lines (accounted by <div>'s)
          $el.find('div').slice(0, lines_to_remove - 1).remove();
        }
      }

      // add each additional new line
      $.each(data.text.split('\n'), function(_, line){
        $el.append($('<div class="line">' + line + '</div>'));
      });

      logChunkData.text = (logChunkData.text + data.text).substr(-buffer_size);
      logChunkData.size = logChunkData.text.length;

      var el = $el.get(0);
      el.scrollTop = Math.max(el.scrollHeight, el.clientHeight) - el.clientHeight;
    }

    function updateTestGroup(data) {
      $scope.$apply(function() {
        var updated = false,
            item_id = data.id,
            attr, result, item;

        // TODO(dcramer); we need to refactor all of this logic as its repeated in nealry
        // every stream
        if ($scope.testGroups.length > 0) {
          result = $.grep($scope.testGroups, function(e){ return e.id == item_id; });
          if (result.length > 0) {
            item = result[0];
            for (attr in data) {
              // ignore dateModified as we're updating this frequently and it causes
              // the dirty checking behavior in angular to respond poorly
              if (item[attr] != data[attr] && attr != 'dateModified') {
                updated = true;
                item[attr] = data[attr];
              }
              if (updated) {
                item.dateModified = data.dateModified;<commit_msg>Dont trim expanded log view<commit_after>define(['app'], function(app) {
  app.controller('buildLogDetailsCtrl', [
      '$scope', '$rootScope', 'initialBuild', 'initialBuildLog', '$window', '$timeout', '$http', '$routeParams', 'stream',
      function($scope, $rootScope, initialBuild, initialBuildLog, $window, $timeout, $http, $routeParams, Stream) {
    'use strict';

    var stream, logChunkData = {
          text: '',
          size: 0,
          nextOffset: 0
        },
        entrypoint = '/api/0/builds/' + $routeParams.build_id + '/logs/' + $routeParams.source_id + '/';

    function updateBuildLog(data) {
      var $el = $('#log-' + data.source.id + ' > .build-log'),
          source_id = data.source.id,
          chars_to_remove, lines_to_remove;

      if (data.offset < logChunkData.nextOffset) {
        return;
      }

      console.log('[Build Log] Got chunk ' + data.id + ' (offset ' + data.offset + ')');

      logChunkData.nextOffset = data.offset + data.size;

      // add each additional new line
      $.each(data.text.split('\n'), function(_, line){
        $el.append($('<div class="line">' + line + '</div>'));
      });

      logChunkData.text += data.text;
      logChunkData.size += data.size;

      var el = $el.get(0);
      el.scrollTop = Math.max(el.scrollHeight, el.clientHeight) - el.clientHeight;
    }

    function updateTestGroup(data) {
      $scope.$apply(function() {
        var updated = false,
            item_id = data.id,
            attr, result, item;

        // TODO(dcramer); we need to refactor all of this logic as its repeated in nealry
        // every stream
        if ($scope.testGroups.length > 0) {
          result = $.grep($scope.testGroups, function(e){ return e.id == item_id; });
          if (result.length > 0) {
            item = result[0];
            for (attr in data) {
              // ignore dateModified as we're updating this frequently and it causes
              // the dirty checking behavior in angular to respond poorly
              if (item[attr] != data[attr] && attr != 'dateModified') {
                updated = true;
                item[attr] = data[attr];
              }
              if (updated) {
                item.dateModified = data.dateModified;
{'fraction_non_alphanumeric': 0.1446553059643687, 'fraction_numerical': 0.004841208365608056, 'mean_word_length': 2.1551618814905313, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, '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': '513997', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1482, 'n_words': 374}