<commit_before>/**
 * Copyright 2014 Flipkart Internet Pvt. Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function LineTile() {
  this.object = "";
}

function getLineChartFormValues() {
  var period = $("#tile-time-unit").val();
  var uniqueCount = $("#uniqueKey").val();
  var timeframe = $("#line-timeframe").val();
  var ignoreDigits = $(".line-ignored-digits").val();

  console.log(uniqueCount);
  if(uniqueCount == "none" || uniqueCount == "" || uniqueCount == null) {
    uniqueCount = null;
  } else {
    uniqueCount = currentFieldList[parseInt(uniqueCount)].field
  }

  return {
    "period": period
    , "uniqueCountOn": uniqueCount
    , "timeframe": timeframe
    , "ignoreDigits" : ignoreDigits
    , };
}

function setLineChartFormValues(object) {
  var parentElement = $("#" + object.tileContext.chartType + "-chart-data");
  var timeUnitEl = parentElement.find("#tile-time-unit");
  timeUnitEl.val(object.tileContext.period);
  $(timeUnitEl).selectpicker('refresh');
  var uniqeKey = parentElement.find("#uniqueKey");
  uniqeKey.val(currentFieldList.findIndex(x => x.field == object.tileContext.uniqueCountOn));
  $(uniqeKey).selectpicker('refresh');
  parentElement.find("#line-timeframe").val(object.tileContext.timeframe);
  $(".line-ignored-digits").val(parseInt(object.tileContext.ignoreDigits == undefined ? 0 : object.tileContext.ignoreDigits));
}

function clearLineChartForm() {
  var parentElement = $("#" + currentChartType + "-chart-data");
  var timeUnitEl = parentElement.find("#tile-time-unit");
  timeUnitEl.find('option:eq(0)').prop('selected', true);
  $(timeUnitEl).selectpicker('refresh');
  var uniqeKey = parentElement.find("#uniqueKey");
  uniqeKey.find('option:eq(0)').prop('selected', true);
  $(uniqeKey).selectpicker('refresh');
  parentElement.find("#line-timeframe").val('');
}
LineTile.prototype.getQuery = function (object) {
  this.object = object;
  var filters = [];
  if(globalFilters) {
    filters.push(timeValue(object.tileContext.period, object.tileContext.timeframe, getGlobalFilters()))
  } else {
    filters.push(timeValue(object.tileContext.period, object.tileContext.timeframe, getPeriodSelect(object.id)))
  }

  if(object.tileContext.filters) {
    for (var i = 0; i < object.tileContext.filters.length; i++) {
      filters.push(object.tileContext.filters[i]);
    }
  }
  var data = {
    "opcode": "histogram"
    , "table": object.tileContext.table
    , "filters": filters
    , "field": "_timestamp"
    , "period": object.tileContext.period
    , "uniqueCountOn": object.uniqueCountOn && object.uniqueCountOn != "none" ? object.uniqueCountOn : null
  }
  $.ajax({
    method: "post"
    , dataType: 'json'
    , accepts: {
      json: 'application/json'
    }<commit_msg>fixed uniquecount on issue in histogram<commit_after>/**
 * Copyright 2014 Flipkart Internet Pvt. Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function LineTile() {
  this.object = "";
}

function getLineChartFormValues() {
  var period = $("#tile-time-unit").val();
  var uniqueCount = $("#uniqueKey").val();
  var timeframe = $("#line-timeframe").val();
  var ignoreDigits = $(".line-ignored-digits").val();

  console.log(uniqueCount);
  if(uniqueCount == "none" || uniqueCount == "" || uniqueCount == null) {
    uniqueCount = null;
  } else {
    uniqueCount = currentFieldList[parseInt(uniqueCount)].field
  }

  return {
    "period": period
    , "uniqueCountOn": uniqueCount
    , "timeframe": timeframe
    , "ignoreDigits" : ignoreDigits
    , };
}

function setLineChartFormValues(object) {
  var parentElement = $("#" + object.tileContext.chartType + "-chart-data");
  var timeUnitEl = parentElement.find("#tile-time-unit");
  timeUnitEl.val(object.tileContext.period);
  $(timeUnitEl).selectpicker('refresh');
  var uniqeKey = parentElement.find("#uniqueKey");
  uniqeKey.val(currentFieldList.findIndex(x => x.field == object.tileContext.uniqueCountOn));
  $(uniqeKey).selectpicker('refresh');
  parentElement.find("#line-timeframe").val(object.tileContext.timeframe);
  $(".line-ignored-digits").val(parseInt(object.tileContext.ignoreDigits == undefined ? 0 : object.tileContext.ignoreDigits));
}

function clearLineChartForm() {
  var parentElement = $("#" + currentChartType + "-chart-data");
  var timeUnitEl = parentElement.find("#tile-time-unit");
  timeUnitEl.find('option:eq(0)').prop('selected', true);
  $(timeUnitEl).selectpicker('refresh');
  var uniqeKey = parentElement.find("#uniqueKey");
  uniqeKey.find('option:eq(0)').prop('selected', true);
  $(uniqeKey).selectpicker('refresh');
  parentElement.find("#line-timeframe").val('');
}
LineTile.prototype.getQuery = function (object) {
  this.object = object;
  var filters = [];
  if(globalFilters) {
    filters.push(timeValue(object.tileContext.period, object.tileContext.timeframe, getGlobalFilters()))
  } else {
    filters.push(timeValue(object.tileContext.period, object.tileContext.timeframe, getPeriodSelect(object.id)))
  }

  if(object.tileContext.filters) {
    for (var i = 0; i < object.tileContext.filters.length; i++) {
      filters.push(object.tileContext.filters[i]);
    }
  }
  var data = {
    "opcode": "histogram"
    , "table": object.tileContext.table
    , "filters": filters
    , "field": "_timestamp"
    , "period": object.tileContext.period
    , "uniqueCountOn": object.tileContext.uniqueCountOn && object.tileContext.uniqueCountOn != "none" ? object.tileContext.uniqueCountOn : null
  }
  $.ajax({
    method: "post"
    , dataType: 'json'
    , accepts: {
      json: 'application/json'
    }
{'fraction_non_alphanumeric': 0.1538111144852718, 'fraction_numerical': 0.0036440935317339812, 'mean_word_length': 4.412489728841413, 'pattern_counts': {'":': 18, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2893207', 'n_tokens_mistral': 2004, 'n_tokens_neox': 1989, 'n_words': 433}