<commit_before>'use strict';

var union = require('lodash/union');
var config = require('collections-online/lib/config');
var cip = require('../../services/cip');
var helpers = require('collections-online/shared/helpers');

const TAGS_VISION_FIELD = helpers.getAssetField('tags_vision');

function saveVisionTags(metadata, tags) {
  if(!TAGS_VISION_FIELD) throw new Error('No vision tag field specified!');
  var values = {};
  values[TAGS_VISION_FIELD] = tags.join(',');
  return cip.setFieldValues(metadata.catalog, metadata.id, 'web', values);
}

module.exports = function(state, metadata) {
  // Let's save some cost and bandwidth and not analyze the asset unless
  // explicitly told. As in run only if one of the indexVison args
  // are specified.
  var runForced = state.indexVisionTagsForce;
  var runDefault = state.indexVisionTags && !metadata.tags_vision;

  if ((runForced || runDefault)) {
    // increment the counter so we can keep track on when to pause and slow down
    state.indexVisionTagsPauseCounter++;

    // Still here. Let's grab the image directly from Cumulus.
    let path = 'preview/thumbnail/' + metadata.catalog + '/' + metadata.id;<commit_msg>Using the layout alias / view from the configuration<commit_after>'use strict';

var union = require('lodash/union');
var config = require('collections-online/lib/config');
var cip = require('../../services/cip');
var helpers = require('collections-online/shared/helpers');

const TAGS_VISION_FIELD = helpers.getAssetField('tags_vision');

function saveVisionTags(metadata, tags) {
  if(!TAGS_VISION_FIELD) {
    throw new Error('No vision tag field specified!');
  }
  var values = {};
  values[TAGS_VISION_FIELD] = tags.join(',');
  const view = config.cip.client.constants.layoutAlias;
  return cip.setFieldValues(metadata.catalog, metadata.id, view, values);
}

module.exports = function(state, metadata) {
  // Let's save some cost and bandwidth and not analyze the asset unless
  // explicitly told. As in run only if one of the indexVison args
  // are specified.
  var runForced = state.indexVisionTagsForce;
  var runDefault = state.indexVisionTags && !metadata.tags_vision;

  if ((runForced || runDefault)) {
    // increment the counter so we can keep track on when to pause and slow down
    state.indexVisionTagsPauseCounter++;

    // Still here. Let's grab the image directly from Cumulus.
    let path = 'preview/thumbnail/' + metadata.catalog + '/' + metadata.id;
{'fraction_non_alphanumeric': 0.1224572823433686, 'fraction_numerical': 0.0, 'mean_word_length': 4.322510822510822, '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': '4772683', 'n_tokens_mistral': 732, 'n_tokens_neox': 717, 'n_words': 221}