# Job

Jobs - a way to run long-running tasks in the background. Jobs are used to run tasks that take a long time to complete, such as syncing data between Crowdin and a third-party service.

Currently, it can be used in the `updateCrowdin` and `updateIntegration` functions of the [Project Integration](/app-project-module/project-integration/) app.

Typical sync jobs call the Crowdin API; reusable helpers (files, folders, translations, webhooks) are summarized in [App Functions](/app-project-module/reference/app-functions/).

The Job object has the following properties:

- `type` - the type of the job (`cron`, `manual`, `rerun`).

## Functions

### `update`

Function to update the job status. It accepts an object with the following fields:

- `progress` - the progress of the job (0-100).
- `status` - the status of the job (`inProgress`, `finished`, `failed`, `canceled`).
- `info` - additional information about the job.
- `data` - additional data about the job.

### `fetchTranslation`

Function to fetch a translation for a specific file and language. It accepts an object with the following fields:

- `fileId` - the ID of the file.
- `languageId` - the ID of the language.
- `params` - (optional) additional parameters for building the translation (e.g., `skipUntranslatedStrings`, `exportApprovedOnly`, etc.). 

### `translationUploaded`

Use this function to notify Crowdin that a translation has been uploaded. It accepts an object with the following fields:

- `fileId` - the ID of the file.
- `translationParams` - an array of objects with the following fields:
  - `languageId` - the ID of the language.
  - `etag` - the etag of the translation.

## Persistence

By default, job executor preserves information about files in database but for large projects with large number of languages and files this could be a bottleneck.
As an alternative, job executor could be configured to store this in memory. But as a consequence it will lose this during redeploys and drawback of this is extra requests for translations.  
To activate in memory store, provide `jobStoreType` for the `projectIntegration` setup.

```js
projectIntegration.jobStoreType = 'in-memory';
```

Read more in the [Upload Only New Translations](/app-project-module/project-integration/#upload-only-new-translations) section.

### `markFilesAsUnsynced`

Function to mark files as unsynced. It accepts an object with the following field:

- `files` - An array of objects, each with a `fileId` (the ID of the file to mark as unsynced) and an `error` (the error that caused the file to be unsynced — an `Error`, an Axios/SDK error, or a string).

Read more in the [Unsynced Files](/app-project-module/project-integration/#unsynced-files) section.