Report. ROCKED candidates performance

Task:


RT-2502

Criteria: Collect the data about processes of ROCKED candidates for the last 12 months

Query:

select
    candidates.id as "candidateId",
    concat_ws(' ', candidates.first_name, candidates.last_name) as "candidateName",
       count(distinct candidates_vacancy_requests.id)   as "numTotal",
       count(distinct candidates_vacancy_requests.id)
       filter (where candidates_vacancy_requests.date_add <=
                     rocked_process.date_update_status) as "numProcessesBeforeBecomingRocked",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '3')               as "numCandidateAccepted",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '4')               as "numCandidateRejected",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '14')              as "numCandidateNoReply",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '6')               as "numShared",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '10')              as "numCompanyAccepted",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '11')              as "numCompanyRejected",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '15')              as "numCompanyNoReply",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value in ('7', '8', '9'))  as "numInterview",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '20')              as "numTrialDay",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '12')              as "numOffered",
       count(distinct arhistory.row_id)
       filter (where arhistory.field_name = 'status'
           and arhistory.new_value = '13')              as "numRocked"
from candidates
         join candidates_vacancy_requests on candidates.id = candidates_vacancy_requests.candidates_id
         join candidates_vacancy_requests as rocked_process on candidates.id = rocked_process.candidates_id
         join arhistory on arhistory.row_id = candidates_vacancy_requests.id and
                           arhistory.table_name = 'candidates_vacancy_requests'
where rocked_process.status = 13
  and date(rocked_process.date_update_status) >= '2022-08-22'
  and date(rocked_process.date_update_status) <= '2023-08-22'
group by candidates.id

Comments

Leave a Reply