mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
New CD
This commit is contained in:
@ -12,8 +12,16 @@
|
||||
*/
|
||||
const knex = require('../utils/knex_config');
|
||||
|
||||
/**
|
||||
* Inserts a new JobApplication.
|
||||
*
|
||||
* @param {*} personId The ID of the Person applying for the job
|
||||
* @param {*} jobOfferId The ID of the job
|
||||
* @returns The inserted JobApplication object if successful, throws an
|
||||
* exception otherwise
|
||||
*/
|
||||
async function insert(personId, jobOfferId) {
|
||||
return await knex('Applicant')
|
||||
return await knex('JobApplication')
|
||||
.insert({
|
||||
person_id: personId,
|
||||
job_offer_id: jobOfferId
|
||||
@ -22,7 +30,7 @@ async function insert(personId, jobOfferId) {
|
||||
}
|
||||
|
||||
async function userAlreadyApplicated(personId, jobOfferId){
|
||||
const person = await knex('Applicant')
|
||||
const person = await knex('JobApplication')
|
||||
.where('person_id', personId)
|
||||
.where('job_offer_id', jobOfferId)
|
||||
.select('*')
|
||||
@ -33,7 +41,23 @@ async function userAlreadyApplicated(personId, jobOfferId){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all the applications of the specified Person, includinf data from
|
||||
* JobOffer and Organization
|
||||
* @param {*} personId
|
||||
* @returns All the applications of the specified Person, throws an exception
|
||||
* otherwise
|
||||
*/
|
||||
async function getApplications(personId){
|
||||
return await knex('JobApplication')
|
||||
.where('person_id', personId)
|
||||
.join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id')
|
||||
.join('Organization', 'Organization.id', 'JobOffer.organization_id')
|
||||
.select('JobApplication.id', 'JobOffer.title', 'JobOffer.description', 'Organization.name', 'Organization.location');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
insert,
|
||||
userAlreadyApplicated
|
||||
userAlreadyApplicated,
|
||||
getApplications
|
||||
}
|
@ -131,5 +131,6 @@ async function filter(title, description, requirements, salary, salaryOperator,
|
||||
module.exports = {
|
||||
insert,
|
||||
remove,
|
||||
findByOrganizationId
|
||||
findByOrganizationId,
|
||||
findById
|
||||
}
|
Reference in New Issue
Block a user