# Cron Tasks Documentation

All cron tasks are stored in the directory: `./src/cron`.

This document provides a detailed overview of each cron task, including its specific requirements and usage.

## 1. synchronizeEcongressPrograms.php

**Purpose**: Synchronizes data between `EcongressSynchro` and `EcongressPlateform` for program-related tasks.

### Requirements:

- Configuration settings should be populated in the table: `services_api_program`.

  - **`ID_cat`**: (Required) Internal ID of the program category.
  - **`servapiprg_url`**: (Required) API URL. Contact the DevOps team for the appropriate environment details.
  - **`servapiprg_token`**: (Required) Bearer authorization token. Contact the DevOps team for the appropriate environment details.
  - **`servapiprg_args`**: (Optional) JSON representation of the required configuration, e.g., `{"api-version":"1.0"}`.
    - **`api-version`**: (Optional, Default: 1.0) Used in the header.

### Command:

```bash
/usr/bin/php7.4 php $WORKDIR/src/cron/synchronizeEcongressPrograms.php $LICENCE_ID
```

## 2. synchronizeEcongressUsers.php

**Purpose**: Synchronizes data between `EcongressSynchro` and `EcongressPlateform` for user-related tasks.

### Requirements (In Progress):

- Configuration settings should be populated in the table: `services_api`.

### Command:

```bash
/usr/bin/php7.4 php $WORKDIR/src/cron/synchronizeEcongressUsers.php $LICENCE_ID
```


## 3. messengerUnreadMessages.php

**Purpose**: Sending count of unread messages of users to Register.

### Arguments :

- **`ID_licence`**: (Required) License ID
- **`ID_service`**: (Optional) service ID
- **`ID_cat`**: (Optional) Internal ID of the program category
- **`forceAll`**: (Optional) if this argument is true, sends count of unread messages for all users
- **`periodicity`**: (Optional) number of minutes between 2 crons

### Command:

```bash
/usr/bin/php7.4 php $WORKDIR/src/cron/messengerUnreadMessages.php --licence-id=ID_licence [--service-id=ID_service] [--cat-id=ID_cat] [--force-all=forceAll] [--periodicity=periodicity]
```


## 3. updateMediaTypeAndContentType.php (ERS)

**Purpose**: Update tags linked with media page depending medias and categories already linked. You need to set tag settings on licence parameters to use Content type link. 
```json
{"TAG_TYPES": {"MEDIA_TYPE": {"id": 9, "content": {"videos": 76, "documents": 77, "audio_podcasts": 79, "external_links": {"id": 78, "ers_journals": {"ERS_JOURNAL_LINK_1": "https://erj.ersjournals.com/content/63/6/2301518"}}}}, "CONTENT_TYPE": {"id": 8, "CHANNEL_ID_TO_TAG_ID": {"185": 343}}}}
```

### Arguments :

- **`licence-id`**: (Required) License ID
- **`service-id`**: (Optional) service ID
- **`start-date`**: (Optional) start date of period at check / default one week ago
- **`end-date`**: (Optional) end date of period at check / default is today
- **`force-all`**: (Optional) Override the default period by older date recorded into database for a media / default is false

### Command:

```bash
/usr/bin/php7.4 php $WORKDIR/src/cron/updateMediaTypeAndContentType.php --licence-id=ID_licence [--service-id=ID_service] [--cat-id=ID_cat] [--date-start=dateStart] [--date-end=dateStart] [--force-all=forceAll] 
```