<commit_before>var angular = require('angular')

require('../app').controller('MonitoringDetailController', /* @ngInject */function ($filter, $http, $scope, $state, $stateParams, $q, $timeout, $translate, model, ngToast, db, Raven, Track, formName, user) {
  var controller = this

  var id = $stateParams.id || $stateParams.fromId

  function genSingleObservationCode () {
    var date = controller.data.observationDateTime || controller.data.startDateTime
    if (date && date.toJSON) { date = date.toJSON() }
    return '!SINGLE-' + date
  }

  function clearGeneratedSingleObservationCode () {
    if (controller.data.monitoringCode === genSingleObservationCode()) {
      controller.data.monitoringCode = null
    }
  }

  function checkCanSave () {
    controller.canSave = !controller.data.user || controller.data.user === user.getIdentity().id || user.canAccess(formName)
  }

  controller.formName = formName
  controller.db = db
  if (id) {
    controller.data = model.get({ id: id })
  } else {
    controller.data = new model() // eslint-disable-line new-cap
    if (angular.isFunction(model.prototype.afterCreate)) { model.prototype.afterCreate.apply(controller.data) }
    checkCanSave()
    // try to fill current location if allowed
    if ('geolocation' in navigator && 'permissions' in navigator) {
      navigator.permissions.query({ name: 'geolocation' })
        .then(function (permission) {
          if (permission.state !== 'granted') return
          navigator.geolocation.getCurrentPosition(function (pos) {
            if (!pos || !pos.coords) return
            // if already populated by some other means
            if (controller.data.latitude != null || controller.data.longitude != null) return
            controller.data.latitude = pos.coords.latitude
            controller.data.longitude = pos.coords.longitude
            checkCanSave()
          }, function (error) {
            Raven.captureMessage(JSON.stringify(error))
          }, {
            enableHighAccuracy: true,
            // 15 sec
            timeout: 15 * 1000,
            // 5 minutes
            maximumAge: 5 * 60 * 1000
          })
        })
    }
  }
  if (!$stateParams.id && $stateParams.fromId) {
    controller.data.$promise.then(function () {
      controller.clearForCopy()
    })<commit_msg>Fill observationDateTime with current timestamp on new record<commit_after>var angular = require('angular')

require('../app').controller('MonitoringDetailController', /* @ngInject */function ($filter, $http, $scope, $state, $stateParams, $q, $timeout, $translate, model, ngToast, db, Raven, Track, formName, user) {
  var controller = this

  var id = $stateParams.id || $stateParams.fromId

  function genSingleObservationCode () {
    var date = controller.data.observationDateTime || controller.data.startDateTime
    if (date && date.toJSON) { date = date.toJSON() }
    return '!SINGLE-' + date
  }

  function clearGeneratedSingleObservationCode () {
    if (controller.data.monitoringCode === genSingleObservationCode()) {
      controller.data.monitoringCode = null
    }
  }

  function checkCanSave () {
    controller.canSave = !controller.data.user || controller.data.user === user.getIdentity().id || user.canAccess(formName)
  }

  controller.formName = formName
  controller.db = db
  if (id) {
    controller.data = model.get({ id: id })
  } else {
    controller.data = new model() // eslint-disable-line new-cap
    controller.data.observationDateTime = new Date()
    if (angular.isFunction(model.prototype.afterCreate)) { model.prototype.afterCreate.apply(controller.data) }
    checkCanSave()
    // try to fill current location if allowed
    if ('geolocation' in navigator && 'permissions' in navigator) {
      navigator.permissions.query({ name: 'geolocation' })
        .then(function (permission) {
          if (permission.state !== 'granted') return
          navigator.geolocation.getCurrentPosition(function (pos) {
            if (!pos || !pos.coords) return
            // if already populated by some other means
            if (controller.data.latitude != null || controller.data.longitude != null) return
            controller.data.latitude = pos.coords.latitude
            controller.data.longitude = pos.coords.longitude
            checkCanSave()
          }, function (error) {
            Raven.captureMessage(JSON.stringify(error))
          }, {
            enableHighAccuracy: true,
            // 15 sec
            timeout: 15 * 1000,
            // 5 minutes
            maximumAge: 5 * 60 * 1000
          })
        })
    }
  }
  if (!$stateParams.id && $stateParams.fromId) {
    controller.data.$promise.then(function () {
      controller.clearForCopy()
    })
{'fraction_non_alphanumeric': 0.12703445360388924, 'fraction_numerical': 0.006763897696047347, 'mean_word_length': 2.779552715654952, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '976992', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1315, 'n_words': 298}