<commit_before>import Document, { DocumentViewType } from '.'

/**
 * @classdesc A JSONAPI document render for Sequelize database results
 * @class
 * @augments {Document}
 */
export default class DatabaseDocument extends Document {
  #result = undefined
  #query = undefined

  /**
   * Create a JSONAPI document from a database result
   * @param query the request query for this document
   * @param result database result
   * @param type the resource type
   * @param view A DocumentViewType enum describing the type of view this document should have
   * @param [meta] extra metdata
   * @constructor
   */
  constructor ({ query, result, type, view = DocumentViewType.individual, meta = {} }) {
    if (result && result.rows) {
      super({
        objects: result.rows,
        type,
        meta: { ...meta, ...query.meta },
        query,
        view: view || DocumentViewType.collection
      })
    } else {
      super({
        objects: result,
        type,
        meta: { ...meta, ...query.meta },
        query,
        view
      })
    }

    this.#result = result
    this.#query = query
  }

  /**
   * @inheritDoc
   */
  get firstPage () {
    if (!this.#result || !this.#result.rows || this.#result.count === 0) {
      return undefined
    }

    return 1
  }

  /**
   * @inheritDoc
   */
  get lastPage () {
    if (!this.#result || !this.#result.rows || this.#result.count === 0) {
      return undefined<commit_msg>Fix bug that was causing problems with rendering search endpoint results<commit_after>import Document, { DocumentViewType } from '.'

/**
 * @classdesc A JSONAPI document render for Sequelize database results
 * @class
 * @augments {Document}
 */
export default class DatabaseDocument extends Document {
  #result = undefined
  #query = undefined

  /**
   * Create a JSONAPI document from a database result
   * @param query the request query for this document
   * @param result database result
   * @param type the resource type
   * @param view A DocumentViewType enum describing the type of view this document should have
   * @param [meta] extra metdata
   * @constructor
   */
  constructor ({ query, result, type, view, meta = {} }) {
    if (result && result.rows) {
      super({
        objects: result.rows,
        type,
        meta: { ...meta, ...query.meta },
        query,
        view: view || DocumentViewType.collection
      })
    } else {
      super({
        objects: result,
        type,
        meta: { ...meta, ...query.meta },
        query,
        view: view || DocumentViewType.individual
      })
    }

    this.#result = result
    this.#query = query
  }

  /**
   * @inheritDoc
   */
  get firstPage () {
    if (!this.#result || !this.#result.rows || this.#result.count === 0) {
      return undefined
    }

    return 1
  }

  /**
   * @inheritDoc
   */
  get lastPage () {
    if (!this.#result || !this.#result.rows || this.#result.count === 0) {
      return undefined
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.002027027027027027, 'mean_word_length': 2.29, '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': '649048', 'n_tokens_mistral': 855, 'n_tokens_neox': 834, 'n_words': 264}