<commit_before>/**
 * Bikeshed model
 */
import Joi from 'joi'
import * as utils from './utils'

export const INDEXES = ['userId', 'createdAt']
export const TABLE = 'bikesheds'
export const TYPE = 'Bikeshed'

export const FileListItemSchema = Joi.object().keys({
  fieldname: Joi.string(),
  originalname: Joi.string(),
  encoding: Joi.string(),
  mimetype: Joi.string(),
  size: Joi.number(),
  key: Joi.string()
})

export const BikeshedSchema = Joi.object().keys({
  createdAt: Joi.date(),
  id: Joi.string().guid(),
  userId: Joi.string().guid(),
  requestId: Joi.string().guid(),
  fileList: Joi.array().min(2).max(8).items(FileListItemSchema),
  description: Joi.string().max(4096).allow('').default('').optional()
})

export const validate = utils.createValidate(BikeshedSchema)

export const get = utils.createGet(TABLE)

export async function create (r, values) {
  const bikeshedValues = validate(values)

  const { generated_keys: [bikeshedId] } = await r.table(TABLE).insert({
    createdAt: r.now(),
    ...bikeshedValues
  })
  return bikeshedId
}<commit_msg>Update Bikeshed to use BaseModel<commit_after>/**
 * Bikeshed model
 */
import Joi from 'joi'
import BaseModel from './model'

const FileListItemSchema = Joi.object()
.keys({
  fieldname: Joi.string(),
  originalname: Joi.string(),
  encoding: Joi.string(),
  mimetype: Joi.string(),
  size: Joi.number(),
  key: Joi.string()
})

const BikeshedSchema = Joi.object()
.keys({
  createdAt: Joi.date(),
  id: Joi.string().guid(),
  userId: Joi.string().guid().required(),
  requestId: Joi.string().guid().required(),
  description: Joi.string().max(4096).allow('').default('').optional(),
  fileList: Joi.array().min(2).max(8).items(FileListItemSchema).required()
})
.requiredKeys(['userId', 'requestId', 'fileList'])

const PROPS = {
  SCHEMA: BikeshedSchema,
  INDEXES: ['userId', 'createdAt'],
  TABLE: 'bikesheds',
  TYPE: 'Bikeshed'
}

export default class Bikeshed extends BaseModel {
}
Object.assign(Bikeshed.prototype, PROPS)
{'fraction_non_alphanumeric': 0.17632367632367632, 'fraction_numerical': 0.005994005994005994, 'mean_word_length': 4.839650145772595, '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': '2728300', 'n_tokens_mistral': 697, 'n_tokens_neox': 696, 'n_words': 153}