zalsaeed / cgav

Certificate Generation and Verification
GNU General Public License v3.0
4 stars 2 forks source link

Show User Progress Bar While Generating Certificates (#43) - "Should Not Use" Fields in Database #79

Open SalmanSaleh1 opened 3 days ago

SalmanSaleh1 commented 3 days ago

In issue #43, I added fields to the database to monitor generation progress, specifically total and progress, in the addCertificate class. These fields are utilized in both certificate_details.html and main.py.

In main.py, I implemented the following functions:

add_progress(event_id): Updates the progress field in the database by incrementing it by 1 for each generated certificate. get_progress(event_id): Retrieves the current progress from the database. set_total(event_id): Sets the total number of certificates for the event.

In certificate_details.html, I modified the JavaScript code to:

Call set_total at the start of the generation process to establish the total number of certificates for the event. Call get_progress every second to update the progress bar displayed in the pop-up, showing the generation progress as a percentage.

SalmanSaleh1 commented 3 days ago

The approach in issue #43 was the last solution, as the task must be completed before the system can proceed with the first feature (V1).

SalmanSaleh1 commented 3 days ago

The main idea of the task was to use AJAX for communication with the backend to update the progress bar. The challenge with this approach lies in the generate_certificate(event_data, output_dir, item_positions) function in main.py, which generates the certificates with a single call. This makes it difficult to monitor or fetch the progress of the generation process.

SalmanSaleh1 commented 3 days ago

Issue #43 needs to be rework because using the database to monitor the generation process is not optimal for system flow and performance.

The new task should start with improving the certificate generation flow to enable effective monitoring of the generation progress.