Backend Utilities and Services
SailPilot’s backend includes various utilities and services essential for the application’s functionality. One key aspect is the background tasks managed in the tasks.py file, particularly for the Features app. These tasks play a vital role in data processing and management, ensuring the application remains up-to-date and efficient.
Background Tasks for Features
The tasks.py file in the Features app includes background tasks essential for the data processing and management of features in the SailPilot application.
process_area Task
The process_area task is responsible for generating JSON files for specific areas and countries.
Purpose: To create or update JSON files containing feature data for a given area and language. This data is used in the SailPilot app for displaying points of interest.
Parameters:
area_name: The name of the area for which the JSON file is to be generated.
country: The country code to determine the applicable languages and point data.
Process:
Determines the applicable languages based on the country.
Normalizes the area name to create a valid file name.
Retrieves or creates a corresponding FeatureLibraries object.
Calls the get_features_data function to fetch feature data with optional encryption.
Writes the feature data to a JSON file.
Updates the FeatureLibraries object with new file details and version.
Usage:
This task is typically scheduled to run in response to specific triggers, such as updates to feature data or periodic refresh requirements. To manually generate area JSON files, follow these steps:
Run the command python manage.py qcluster in the terminal to start the task queue.
Visit https://app.sail-pilot.com/features/schedule-json-generation/ to trigger the task.
If the task continues running after one version increment, stop the process.
Reload the terminal, re-enter the virtual environment, and run pkill -f ‘manage.py qcluster’ to reset the task queue.
Note
These steps ensure the proper initiation, execution, and reset (if necessary) of the background task for generating area JSON files.