---
# System prepended metadata

title: IPT revamp documentation

---

# IPT revamp documentation
How to maintain this document:
1. Jot down ideas/designs here **while you work**.
2. Easily copy-paste your docs into PR description.
3. Include images
4. Include postman links
5. Include [fancy drawings](https://hackmd.io/features#UML-Diagrams).

-----
# Resumes

### Zipping/Downloading multiple resumes
Notes:
- [Usage] Ideally there shouldn't be a need to use the `getAllFiles` controller(/resume/files-all)
- [Usage] `getFiles` service can be used by other modules; just needs a `ResumeModel[]`. 
- resume-applicant-student is queried multiple times (but only if headered resume is not in cache); keeps logics separate
- Not saving zips on disk
-----

# Academics Module

## Qualifications

Qualifications for an applicant need to collectively satisfy some criteria involving levels:
- Postdocs should have a qualification of level 'Doctorate' and 'Graduation'
- Doctorates and Postgraduates should have a qualfication of level 'Graduation'
- Everyone should have qualifications of levels 'Intermediate' and 'Matriculation'

To enforce this, the API has been designed in the following manner:
- The create end point accepts
    - a json containing a `qualifications` array
        - the `specialization` field is optional
    - If the level criteria is already satisfied from previous insertions, this will insert more without any errors
        - Thus, levels must be satisfied in the first insertion request
            - Raises UnprocessableEntityError otherwise
- Requests to delete endpoint succeed if deletion does not result in dissatisfaction of the levels criteria
    - Raises UnprocessableEntityError otherwise
- The update endpoint does not allow updates to levels, for the sake of simplicity

----

# Company

## Tracker

Trackers represent the company-coordinator (CC) relationship. Active Trackers are the ones with `accessFrom <= now() <= accessUntil`. Unless stated (or asked for, e.g. in /tracker), all returned trackers are active.

While creating company, a tracker is also created, with `coordinator` and `createdBy` both being `request.user`.

GET `/tracker`

    Optional parameters: *default*

    "inactive":           false  [if true, returns all trackers]
    "coordinatorId": 
    "companyId":
    "createdById":

GET `/company/:companyId/tracker`

POST `/tracker`
Will succeed only for CCs and APCs; otherwise raises `UnprocessableEntityError`

    Parameters:           *default*
     "companyId": 
     "coordinatorId":
     "accessFrom":        *now()*
     "accessUntil":       *now() + 1 year*

DELETE `/tracker/:id`
Allows deletion of tracker if a) `AccessUntil` has passed OR b) Company has >1 *active* trackers

-----
# Seeding data

- Seed files are present in cindex/src/database/seeds.
- Knex doesn't have support for saving seed run status, i.e whether a seed has been run or not. So if you run `npm run seed` multiple times, it will be executed again. So we created a custom knex_seeds table to track this.
- Each seed file contains a check at the top so that it doesn't get executed more than once.
- Some seeds need to be run only for dev/test environment. So we just wrote a check at the top to check the env. The seed.stub file allows the seed to run for all envs. Remove the env from the `forEnv` variable, that you don't want to run the seed in.

----

# Flare

- Group together related components into modules.
- All api calls are implemented inside services.
- All routes are based off app-routing.module.ts.
- Nested routes are implemented inside modules.
- Sidebars are inside shared/components

## Role switching
- JWT includes roles concatenated into a string with '-' separator.
- After login, roles are split and if 'applicant' exists in roles, then student is taken to applicant dashboard, else to coordinator dashboard
- In applicant dashboard, if roles includes any of the coordinator roles, then a 'switch to coordinator' button is shown
- Similarly, a 'switch to applicant' button is shown in coordinator dashboard.

## Downloading files
- There are 2 ways to "download" a file - initiate a direct browser download or open the file in a new tab from where the user can choose to view/download/print.
- The first method is accomplished using a hack. We create a dummy anchor tag, change its href and simulate a click. This has been implemented in utilService.downloadFile(file, fileName)
- The second approach has been implemented in 2 ways
    - Open the file in a browser tab as is, and let the browser take care of rendering it. To do this call utilService.displayFile(file)
    - If the file is a PDF, we can display it using the PDF js plugin. Create an ng2-pdfjs-viewer element in the component html and trigger it using a function. Refer resume/list/list.component.ts for use case