<commit_before>// Mongo database schemas
// Separate into different files before integrating to master

var mongoose = require('mongoose');
var model = mongoose.model;
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;


//SKILLS
var skillSchema = new Schema({
  name: { type: String },
  rating: { type: Number}
});

var Skill = mongoose.model('Skill', skillSchema);

//MESSAGES
var messageSchema = new Schema({
  // This should be the ID of the sending user
  // If it isn't the user this message list was retrieved
  // from then it was sent to them from someone else
  sender: { type: ObjectId },
  text: { type: String }
}, { timestamps: true });

var Message = mongoose.model('Message', messageSchema);

//USERS
var userSchema = new Schema({
  username: { type: String },
  passwordHash: { type: String },
  twoFactorMethod: { type: String },
  name: { type: String },
  title: { type: String },
  skillTags: [skillSchema],
  bio: { type: String },
  email: { type: String },
  isVerified: { type: Boolean, default: false },
  timeVerified: { type: Date },
  powerLevel: { type: Number, default: 0 },
  // Refer to http://stackoverflow.com/questions/4677237
  // for further explanation of why this is the case
  followings: [ObjectId],
  messages: [messageSchema],
  contacts: [ObjectId],
  blocked: [ObjectId],
  contracts: [ObjectId]
}, { collection : 'users', timestamps: true });

var User = mongoose.model('User', userSchema);

//PROJECT MEMBERS
var projectMemberSchema = new Schema({
  user: { type: ObjectId }
}, { timestamps: true });

var ProjectMember = mongoose.model('ProjectMember', projectMemberSchema);

//PROJECT INFO
var detailedProjectInfoSchema = new Schema({
  title: { type: String },
  content: { type: String }
});

var DetailedInfo = mongoose.model('DetailedInfo', detailedProjectInfoSchema);

//SHOWCASE
var showcaseSchema = new Schema({
  project: { type: ObjectId },
  // Display order inferred from indices
  assetPaths: [String],
  // Can extract mediatype from full path
  mediaTypes: [String]
}, { collection: 'showcases', timestamps: true });

var Showcase = mongoose.model('Showcase', showcaseSchema);

//PROJECT
var projectSchema = new Schema({
  name: { type: String },
  tags: [String],
  ownerUsername: { type: String },
  members: [projectMemberSchema],
  contracts: { type: ObjectId },
  showcase: { type: showcaseSchema },
  basicInfo: { type: String },
  detailedInfo: [detailedInfoSchema],
  status: { type: String }
}, { collection : 'projects',timestamps: true });

var Project = mongoose.model('Project', projectSchema);

var contractSchema = new Schema({
  name: { type: String },
  intro: { type: String },
  status: { type: String},
  skillTags: [skillSchema],
  descriptionTags: [String],
  // ID of project member who created the contract
  project: { ObjectId },
  owner: { ObjectId },
  project: { ObjectId },
  takers: [ObjectId],
  details: { type: String },
  deadline: { type: Date },
  budget: { type: Number }
}, { timestamps: true });

var Contract = mongoose.model('Contract', contractSchema);

var reportSchema = new Schema({
  reporter: { type: ObjectId },
  reportee: { type: ObjectId },
  reason: { type: String },
  webpage: { type: String },
  status: { type: String }
}, { collection: 'reports', timestamps: true });

var Report = mongoose.model('Report', contractSchema);

module.exports.Skill = Skill;
module.exports.Message = Message;
module.exports.User = User;
module.exports.DetailedInfo = DetailedInfo;
module.exports.ProjectMember = ProjectMember;<commit_msg>Extended db schemas for specificity<commit_after>// Mongo database schemas
// Separate into different files before integrating to master

var mongoose = require('mongoose');
var model = mongoose.model;
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;


//SKILLS
var skillSchema = new Schema({
  name: {
    type: String,
    required: true},
  rating: {
    type: Number,
    required: true,
    min: [0, 'Skill must be at least 0'],
    max: [5, 'Skill must be no greater than 5']
  }
});

var Skill = mongoose.model('Skill', skillSchema);

//MESSAGES
var messageSchema = new Schema({
  // This should be the ID of the sending user
  // If it isn't the user this message list was retrieved
  // from then it was sent to them from someone else
  sender: {
    type: ObjectId,
    required: true
  },
  text: {
    type: String,
    required: true
  }
}, { timestamps: true });

var Message = mongoose.model('Message', messageSchema);

//USERS
var userSchema = new Schema({
  username: {
    type: String,
    required: true
  },
  passwordHash: {
    type: String,
    required: true
  },
  twoFactorMethod: {
    type: String
  },
  name: {
    type: String
  },
  title: {
    type: String
  },
  skillTags: [skillSchema],
  bio: {
    type: String
  },
  email: {
    type: String ,
    required: true
  },
  isVerified: {
    type: Boolean,
    default: false
  },
  timeVerified: {
    type: Date
  },
  powerLevel: {
    type: Number,
    default: 0
  },
  // Refer to http://stackoverflow.com/questions/4677237
  // for further explanation of why this is the case
  followings: [ObjectId],
  messages: [messageSchema],
  contacts: [ObjectId],
  blocked: [ObjectId],
  contracts: [ObjectId]
}, { collection : 'users', timestamps: true });

var User = mongoose.model('User', userSchema);

//PROJECT MEMBERS
var projectMemberSchema = new Schema({
  user: {
    type: ObjectId,
    required: true
  }
}, { timestamps: true });

var ProjectMember = mongoose.model('ProjectMember', projectMemberSchema);

//PROJECT INFO
var detailedProjectInfoSchema = new Schema({
  title: {
    type: String,
    required: true
  },
  content: {
    type: String,
    required: true
  }
});

var DetailedInfo = mongoose.model('DetailedInfo', detailedProjectInfoSchema);

//SHOWCASE
var showcaseSchema = new Schema({
  project: { type: ObjectId },
  // Display order inferred from indices
  assetPaths: [String],
  // Can extract mediatype from full path
  mediaTypes: [String]
}, { collection: 'showcases', timestamps: true });

var Showcase = mongoose.model('Showcase', showcaseSchema);

//PROJECT
var projectSchema = new Schema({
  name: {
    type: String,
    required: true
  },
  tags: [String],
  ownerUsername: {
    type: String,
    required: true
  },
  members: [projectMemberSchema],
  contracts: {
    type: ObjectId
  },
  showcase: {
    type: showcaseSchema
  },
  basicInfo: {
    type: String
  },
  detailedInfo: [detailedInfoSchema],
  status: {
    type: String
  }
}, { collection : 'projects',timestamps: true });

var Project = mongoose.model('Project', projectSchema);

var contractSchema = new Schema({
  name: {
    type: String,
    required: true
  },
  intro: {
    type: String
  },
  status: {
    type: String
  },
  skillTags: [skillSchema],
  descriptionTags: [String],
  // ID of project member who created the contract
  project: {
    ObjectId,
    required: true
  },
  owner: {
    ObjectId,
    required: true
  },
  takers: [ObjectId],
  details: {
    type: String
  },
  deadline: {
    type: Date,
    required: true
  },
  budget: {
    type: Number,
    required: true
  }
}, { timestamps: true });

var Contract = mongoose.model('Contract', contractSchema);

var reportSchema = new Schema({
  reporter: {
    type: ObjectId,
    required: true
  },
  reportee: {
    type: ObjectId,
    required: true
  },
  reason: {
    type: String,
    required: true
  },
  webpage: {
    type: String,
    required: true
  },
  status: {
    type: String,
    required: true
  }
}, { collection: 'reports', timestamps: true });

var Report = mongoose.model('Report', contractSchema);

module.exports.Skill = Skill;
module.exports.Message = Message;
module.exports.User = User;
module.exports.DetailedInfo = DetailedInfo;
module.exports.ProjectMember = ProjectMember;
{'fraction_non_alphanumeric': 0.13091001525165227, 'fraction_numerical': 0.002541942043721403, 'mean_word_length': 3.5433025404157044, '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': '2070823', 'n_tokens_mistral': 2464, 'n_tokens_neox': 2470, 'n_words': 740}