<commit_before>const { DataTypes } = require('sequelize')
const languageField = require('../utils/languageField')

const labelField = languageField('label', {
  dataType: DataTypes.TEXT
})
const summaryField = languageField('summary', { dataType: DataTypes.TEXT })
const urlField = languageField('url', { dataType: DataTypes.TEXT })

module.exports = function (sequelize, DataTypes) {
  const attributes = {
    enabled: DataTypes.BOOLEAN,
    type: DataTypes.STRING(32),
    ...labelField.attributes,
    ...summaryField.attributes,
    ...urlField.attributes,
    tileWidth: DataTypes.INTEGER,
    tileHeight: DataTypes.INTEGER
  }

  const options = {
    instanceMethods: {
      apiData: function () {
        return {
          id: this.id,
          enabled: this.enabled,
          type: this.type,
          label: labelField.values(this),
          summary: summaryField.values(this),
          url: urlField.values(this),
          tileWidth: this.tileWidth,
          tileHeight: this.tileHeight
        }
      },
      apiUpdate: function (data) {
        if (data.enabled != null) {
          this.enabled = data.enabled
        }
        if (data.type) {
          this.type = data.type
        }
        if (data.label) {
          labelField.update(this, data.label)
        }
        if (data.summary) {
          summaryField.update(this, data.summary)
        }
        if (data.url) {
          summaryField.update(this, data.url)
        }
        if (data.tileWidth != null) {
          this.tileWidth = data.tileWidth
        }
        if (data.tileHeight != null) {
          this.tileHeight = data.tileHeight
        }
      }
    }
  }

  const MapLayer = sequelize.define('MapLayer', attributes, options)

  return MapLayer
}<commit_msg>feat(layers): fix update of map layers<commit_after>const { DataTypes } = require('sequelize')
const languageField = require('../utils/languageField')

const labelField = languageField('label', {
  dataType: DataTypes.TEXT
})
const summaryField = languageField('summary', { dataType: DataTypes.TEXT })
const urlField = languageField('url', { dataType: DataTypes.TEXT })

module.exports = function (sequelize, DataTypes) {
  const attributes = {
    enabled: DataTypes.BOOLEAN,
    type: DataTypes.STRING(32),
    ...labelField.attributes,
    ...summaryField.attributes,
    ...urlField.attributes,
    tileWidth: DataTypes.INTEGER,
    tileHeight: DataTypes.INTEGER
  }

  const options = {
    instanceMethods: {
      apiData: function () {
        return {
          id: this.id,
          enabled: this.enabled,
          type: this.type,
          label: labelField.values(this),
          summary: summaryField.values(this),
          url: urlField.values(this),
          tileWidth: this.tileWidth,
          tileHeight: this.tileHeight
        }
      },
      apiUpdate: function (data) {
        if (data.enabled != null) {
          this.enabled = data.enabled
        }
        if (data.type) {
          this.type = data.type
        }
        if (data.label) {
          labelField.update(this, data.label)
        }
        if (data.summary) {
          summaryField.update(this, data.summary)
        }
        if (data.url) {
          urlField.update(this, data.url)
        }
        if (data.tileWidth != null) {
          this.tileWidth = data.tileWidth
        }
        if (data.tileHeight != null) {
          this.tileHeight = data.tileHeight
        }
      }
    }
  }

  const MapLayer = sequelize.define('MapLayer', attributes, options)

  return MapLayer
}
{'fraction_non_alphanumeric': 0.11961722488038277, 'fraction_numerical': 0.001125809175344779, 'mean_word_length': 2.1340388007054676, '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': '5186580', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1023, 'n_words': 207}