<commit_before>"use strict";

import endpoint from "./endpoint";
import * as requests from "./requests";

/**
 * Abstract representation of a exhibition.
 */
export default class Exhibition {

  /**
   * Constructor.
   *
   * @param  {Tenant} tenant     The tenant instance.
   * @param  {String} exhibitionId  The exhibition id.
   */
  constructor(tenant, exhibitionId) {

    /**
     * The tenant.
     * @type {Tenant}
     */
    this.tenant = tenant;

    /**
     * The value id.
     * @type {String}
     */
    this.exhibitionId = exhibitionId;
  }

  /**
   * Retrieves exhibition.
   *
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  get(options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibition", this.exhibitionId)
      },
      options
    );
  }

  /**
   * Updates the value with the specified properties.
   *
   * @param {String} visibility     The exhibition visibility
   * @param  {Object} options       The options object.
   * @return {Promise<Object, Error>}
   */
  changeExhibitionVisibility(visibility, options = {}) {
    return this.tenant.execute(
      requests.changeExhibitionVisibility(this.exhibitionId, visibility),
      options
    );
  }

  /**
   * Updates the description of the exhibition.
   *
   * @param {String} name           The exhibition name.
   * @param {String} description    The exhibition description.
   * @param {String} pictureUri     The exhibition picture.
   * @param  {Object} options       The options object.
   * @return {Promise<Object, Error>}
   */
  update(name, description, pictureUri, options = {}) {
    return this.tenant.execute(
      requests.updateExhibition(this.exhibitionId, name, description, pictureUri),
      options
    );
  }

  /**
   * Delete current exhibition
   *
   * @param  {Object} options             The options object.
   * @returns {Promise.<Object, Error>}
   */
  remove(options = {}) {
    return this.tenant.execute(
      requests.deleteExhibition(this.exhibitionId),
      options
    );
  }

  /**
   * Retrieves exhibition clusters.
   *
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  getPublishedClusters(options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibitionClusters", this.exhibitionId)
      },
      options
    ).then((response) => {
      if (response) {
        return response;
      } else {
        return {};
      }
    });
  }

  /**
   * Retrieves exhibition instances.
   *
   * @param  {String} instanceId      The instance id.
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  getPublishedInstances(options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibitionInstances", this.exhibitionId)
      },
      options
    ).then((response) => {
      if (response["_embedded"]) {
        return response["_embedded"]["be:instance"].forEach((instance) => {
          instance.users = response["_embedded"]["be:user"];
        });
      } else {
        return [];
      }
    });
  }

  /**
   * Retrieves exhibition instances.
   * @param  {String} instanceId      The id of the instance.
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  getPublishedInstance(instanceId, options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibitionInstance", this.exhibitionId, instanceId)
      },
      options
    ).then((response) => {
      response.users = response["_embedded"]["be:user"];<commit_msg>Correctly return published instance<commit_after>"use strict";

import endpoint from "./endpoint";
import * as requests from "./requests";

/**
 * Abstract representation of a exhibition.
 */
export default class Exhibition {

  /**
   * Constructor.
   *
   * @param  {Tenant} tenant     The tenant instance.
   * @param  {String} exhibitionId  The exhibition id.
   */
  constructor(tenant, exhibitionId) {

    /**
     * The tenant.
     * @type {Tenant}
     */
    this.tenant = tenant;

    /**
     * The value id.
     * @type {String}
     */
    this.exhibitionId = exhibitionId;
  }

  /**
   * Retrieves exhibition.
   *
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  get(options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibition", this.exhibitionId)
      },
      options
    );
  }

  /**
   * Updates the value with the specified properties.
   *
   * @param {String} visibility     The exhibition visibility
   * @param  {Object} options       The options object.
   * @return {Promise<Object, Error>}
   */
  changeExhibitionVisibility(visibility, options = {}) {
    return this.tenant.execute(
      requests.changeExhibitionVisibility(this.exhibitionId, visibility),
      options
    );
  }

  /**
   * Updates the description of the exhibition.
   *
   * @param {String} name           The exhibition name.
   * @param {String} description    The exhibition description.
   * @param {String} pictureUri     The exhibition picture.
   * @param  {Object} options       The options object.
   * @return {Promise<Object, Error>}
   */
  update(name, description, pictureUri, options = {}) {
    return this.tenant.execute(
      requests.updateExhibition(this.exhibitionId, name, description, pictureUri),
      options
    );
  }

  /**
   * Delete current exhibition
   *
   * @param  {Object} options             The options object.
   * @returns {Promise.<Object, Error>}
   */
  remove(options = {}) {
    return this.tenant.execute(
      requests.deleteExhibition(this.exhibitionId),
      options
    );
  }

  /**
   * Retrieves exhibition clusters.
   *
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  getPublishedClusters(options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibitionClusters", this.exhibitionId)
      },
      options
    ).then((response) => {
      if (response) {
        return response;
      } else {
        return {};
      }
    });
  }

  /**
   * Retrieves exhibition instances.
   *
   * @param  {String} instanceId      The instance id.
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  getPublishedInstances(options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibitionInstances", this.exhibitionId)
      },
      options
    ).then((response) => {
      if (response["_embedded"]) {
        response["_embedded"]["be:instance"].forEach((instance) => {
          instance.users = response["_embedded"]["be:user"];
        });
        return response["_embedded"]["be:instance"];
      } else {
        return [];
      }
    });
  }

  /**
   * Retrieves exhibition instances.
   * @param  {String} instanceId      The id of the instance.
   * @param  {Object} options         The options object.
   * @return {Promise<Object, Error>}
   */
  getPublishedInstance(instanceId, options = {}) {
    return this.tenant.execute(
      {
        path: endpoint("exhibitionInstance", this.exhibitionId, instanceId)
      },
      options
    ).then((response) => {
      response.users = response["_embedded"]["be:user"];
{'fraction_non_alphanumeric': 0.1315505132360886, 'fraction_numerical': 0.0, 'mean_word_length': 2.3400992331980155, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, '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': '7512197', 'n_tokens_mistral': 2178, 'n_tokens_neox': 2153, 'n_words': 499}