<commit_before>path = require 'path-extra'
{React, ReactBootstrap, $} = window
{Grid, Row, Col, ButtonGroup, DropdownButton, MenuItem} = ReactBootstrap

Chart = require '../assets/Chart'

toDateLabel = (datetime) ->
  date = new Date(datetime)
  "#{date.getFullYear()}/#{date.getMonth() + 1}/#{date.getDate()}-#{date.getHours()}"
toDateString = (datetime)->
  date = new Date(datetime)
  "#{date.getFullYear()}/#{date.getMonth() + 1}/#{date.getDate()}"

AkashicResourceChart = React.createClass
  getInitialState: ->
    rowChooseChecked: [true, true, true, true, true, true, true, true, true, true, true, true,
                      true, true]
    showScale: "天"
    showRange: "最近一周"
  showAsDay: true
  showRange: 7
  showScaleChange: false
  resourceChart: null
  wholeDataLength: 0
  dataLength: 0
  data:
    labels: [],
    datasets: [
      {
        label: "燃",
        fillColor: "rgba(27,154,25,0.2)",
        strokeColor: "rgba(27,154,25,1)",
        pointColor: "rgba(27,154,25,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(27,154,25,1)",
        data: []
      },
      {
        label: "弹",
        fillColor: "rgba(102,57,16,0.2)",
        strokeColor: "rgba(102,57,16,1)",
        pointColor: "rgba(102,57,16,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(102,57,16,1)",
        data: []
      },
      {
        label: "钢",
        fillColor: "rgba(145,145,145,0.2)",
        strokeColor: "rgba(145,145,145,1)",
        pointColor: "rgba(145,145,145,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(145,145,145,1)",
        data: []
      },
      {
        label: "铝",
        fillColor: "rgba(179,124,80,0.2)",
        strokeColor: "rgba(179,124,80,1)",
        pointColor: "rgba(179,124,80,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(179,124,80,1)",
        data: []
      },
      {
        label: "高速建造",
        fillColor: "rgba(251,138,0,0.2)",
        strokeColor: "rgba(251,138,0,1)",
        pointColor: "rgba(251,138,0,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(251,138,0,1)",
        data: []
      },
      {
        label: "高速修复",
        fillColor: "rgba(50,236,161,0.2)",
        strokeColor: "rgba(50,236,161,1)",
        pointColor: "rgba(50,236,161,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(50,236,161,1)",
        data: []
      },
      {
        label: "资材",
        fillColor: "rgba(65,155,169,0.2)",
        strokeColor: "rgba(65,155,169,1)",
        pointColor: "rgba(65,155,169,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(65,155,169,1)",
        data: []
      },
      {
        label: "螺丝",
        fillColor: "rgba(170,170,170,0.2)",
        strokeColor: "rgba(170,170,170,1)",
        pointColor: "rgba(170,170,170,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(170,170,170,1)",
        data: []
      }
    ]
  dataFilter: (data)->
    dateString = ""
    showAsDay = @showAsDay
    dayBegin = (new Date()).getTime() - 86400000 * @showRange
    data.filter (item)->
      if item[0] <= dayBegin
        false
      else if showAsDay
        tmp = toDateString item[0]
        if tmp isnt dateString
          dateString = tmp
          true
        else
          false
      else
        true
  componentDidMount: ->
    console.log "map init"
  componentDidUpdate: ->
    if @resourceChart is null and @props.mapShowFlag
      ctx = document.getElementById("myChart").getContext("2d")
      Chart.defaults.global.responsive = true
      @resourceChart = new Chart(ctx).Line(@data)
      _data = @dataFilter @props.data
      @dataLength = _data.length
      @wholeDataLength = @props.data.length
      _data.reverse()
      @resourceChart.options.animation = false
      for log in _data
        @resourceChart.addData(log[1..9], toDateLabel(log[0]))
      @resourceChart.options.animation = true
      console.log "map create"
  shouldComponentUpdate: (nextProps, nextState)->
    console.log "in shouldComponentUpdate"
    if @resourceChart is null
      true
    else if nextState.showRange isnt @state.showRange or nextState.showScale isnt @state.showScale
      _data = @dataFilter @props.data
      _data.reverse()
      @resourceChart.options.animation = false<commit_msg>clean console.log<commit_after>path = require 'path-extra'
{React, ReactBootstrap, $} = window
{Grid, Row, Col, ButtonGroup, DropdownButton, MenuItem} = ReactBootstrap

Chart = require '../assets/Chart'

toDateLabel = (datetime) ->
  date = new Date(datetime)
  "#{date.getFullYear()}/#{date.getMonth() + 1}/#{date.getDate()}-#{date.getHours()}"
toDateString = (datetime)->
  date = new Date(datetime)
  "#{date.getFullYear()}/#{date.getMonth() + 1}/#{date.getDate()}"

AkashicResourceChart = React.createClass
  getInitialState: ->
    rowChooseChecked: [true, true, true, true, true, true, true, true, true, true, true, true,
                      true, true]
    showScale: "天"
    showRange: "最近一周"
  showAsDay: true
  showRange: 7
  showScaleChange: false
  resourceChart: null
  wholeDataLength: 0
  dataLength: 0
  data:
    labels: [],
    datasets: [
      {
        label: "燃",
        fillColor: "rgba(27,154,25,0.2)",
        strokeColor: "rgba(27,154,25,1)",
        pointColor: "rgba(27,154,25,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(27,154,25,1)",
        data: []
      },
      {
        label: "弹",
        fillColor: "rgba(102,57,16,0.2)",
        strokeColor: "rgba(102,57,16,1)",
        pointColor: "rgba(102,57,16,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(102,57,16,1)",
        data: []
      },
      {
        label: "钢",
        fillColor: "rgba(145,145,145,0.2)",
        strokeColor: "rgba(145,145,145,1)",
        pointColor: "rgba(145,145,145,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(145,145,145,1)",
        data: []
      },
      {
        label: "铝",
        fillColor: "rgba(179,124,80,0.2)",
        strokeColor: "rgba(179,124,80,1)",
        pointColor: "rgba(179,124,80,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(179,124,80,1)",
        data: []
      },
      {
        label: "高速建造",
        fillColor: "rgba(251,138,0,0.2)",
        strokeColor: "rgba(251,138,0,1)",
        pointColor: "rgba(251,138,0,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(251,138,0,1)",
        data: []
      },
      {
        label: "高速修复",
        fillColor: "rgba(50,236,161,0.2)",
        strokeColor: "rgba(50,236,161,1)",
        pointColor: "rgba(50,236,161,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(50,236,161,1)",
        data: []
      },
      {
        label: "资材",
        fillColor: "rgba(65,155,169,0.2)",
        strokeColor: "rgba(65,155,169,1)",
        pointColor: "rgba(65,155,169,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(65,155,169,1)",
        data: []
      },
      {
        label: "螺丝",
        fillColor: "rgba(170,170,170,0.2)",
        strokeColor: "rgba(170,170,170,1)",
        pointColor: "rgba(170,170,170,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(170,170,170,1)",
        data: []
      }
    ]
  dataFilter: (data)->
    dateString = ""
    showAsDay = @showAsDay
    dayBegin = (new Date()).getTime() - 86400000 * @showRange
    data.filter (item)->
      if item[0] <= dayBegin
        false
      else if showAsDay
        tmp = toDateString item[0]
        if tmp isnt dateString
          dateString = tmp
          true
        else
          false
      else
        true
  componentDidMount: ->
    console.log "map init"
  componentDidUpdate: ->
    if @resourceChart is null and @props.mapShowFlag
      ctx = document.getElementById("myChart").getContext("2d")
      Chart.defaults.global.responsive = true
      @resourceChart = new Chart(ctx).Line(@data)
      _data = @dataFilter @props.data
      @dataLength = _data.length
      @wholeDataLength = @props.data.length
      _data.reverse()
      @resourceChart.options.animation = false
      for log in _data
        @resourceChart.addData(log[1..9], toDateLabel(log[0]))
      @resourceChart.options.animation = true
      console.log "map create"
  shouldComponentUpdate: (nextProps, nextState)->
    if @resourceChart is null
      true
    else if nextState.showRange isnt @state.showRange or nextState.showScale isnt @state.showScale
      _data = @dataFilter @props.data
      _data.reverse()
      @resourceChart.options.animation = false
{'fraction_non_alphanumeric': 0.1567654986522911, 'fraction_numerical': 0.06706199460916443, 'mean_word_length': 2.5096481271282634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '5811391', 'n_tokens_mistral': 3501, 'n_tokens_neox': 3166, 'n_words': 567}