phpvms icon indicating copy to clipboard operation
phpvms copied to clipboard

Double clicking Acars > File Pirep button causes a non defined status to be written to database

Open FatihKoz opened this issue 2 years ago • 5 comments

When a pilot accidentally (or intentionally) double clicks the File Pirep button at acars below happens;

  1. First Click's request sends the pirep, phpvms starts processing the request.
  2. Second Click's requests remains on hold, waiting for the first to be finished.

First requests accepts/rejects the pirep, in our example it is accepted.

State = 2 (Accepted), Status = 'ONB' (Arrived)

Moments after this, second request starts being processed. And gets the exception from duplicate pirep checks, but acars sends the update request like this {'status' = 'FIL'}. Most probably it is an internal code used by acars 'cause it is not defined in App\Models\Enums\PirepStatus.php and not being used by phpvms.

Even though it is not defined and this is a definite duplicate filing attempt, that info gets into the database and pirep gets updated

State = 2 (Accepted), Status = 'FIL'

Version vmsACARS Version: 1.0.0.2000 phpVMS Version: 7.0.0-dev+220217.648659

To Reproduce

  1. Try clicking the File Pirep button twice (or set your mouse to auto double click)
  2. Check both acars\logs\log.txt and phpvms\storage\logs\laravel.log
  3. Check the database record for that pirep

Expected behavior

  • That status change should not happen at database level. If a pirep is filed before and if the second attempt is identified as a duplicate, it should not proceed further and reach database.
  • Acars should send phpVms recognizable values only, if that 'FIL' is somehow necessary then it should have a matching enum definition at phpvms too.

Additional context vmsAcars Log;

02-24 17:22:21|INFO; Setting flight phase to Arrived
02-24 17:22:22|INFO; Handling action button, val=File Flight
02-24 17:22:22|INFO; Handling action button, val=File Flight
02-24 17:22:25|INFO; PIREP File for 9PplR7m2GZRQR1GZ was successful, request time=3022ms
02-24 17:22:25|INFO; Setting flight phase to Filed
02-24 17:22:25|INFO; MessageBox, message=PIREP has been filed!
02-24 17:22:25|INFO; Removing PIREP from local, id=$1
02-24 17:22:25|INFO; Setting flight phase to Not Running
02-24 17:22:26|ERROR; error=PIREP has already been submitted
02-24 17:22:26|ERROR; code=400
02-24 17:22:26|INFO; Error filing PIREP, PIREP has already been submitted
02-24 17:22:26|INFO; MessageBox, message=There was an error filing the PIREP

phpVMS Log;

[2022-02-24 14:22:21] production.INFO: NotificationEvents::onPirepFile: 9PplR7m2GZRQR1GZ filed  
[2022-02-24 14:22:22] production.INFO: PIREP 9PplR7m2GZRQR1GZ state change to ACCEPTED
[2022-02-24 14:22:22] production.INFO: Finance: Starting PIREP pay for 9PplR7m2GZRQR1GZ
[2022-02-24 14:22:24] production.INFO: PIREP Update, user 106  
[2022-02-24 14:22:24] production.INFO: {"status":"FIL"}  
[2022-02-24 14:22:24] production.INFO: NotificationEvents::onPirepStatusChange: 9PplR7m2GZRQR1GZ status changed  
[2022-02-24 14:22:25] production.INFO: PIREP file, user 106 {"id":"9PplR7m2GZRQR1GZ","airline_id":1,"aircraft_id":6,"flight_id":"RMr0nDX3e71YePgJ","simbrief_id":"1645705290_67284E6243","flight_number":"2201","route_leg":"4","route_code":"DOM22","flight_type":"G","planned_distance":787.97,"distance":791.18,"status":"FIL","dpt_airport_id":"LTBJ","arr_airport_id":"LTCI","level":33000,"route":"MEN D340F D340H D029H D056H VAKUM KULAR NESET TUMER KINIK KFK ROLVI HALIL HAY AZBUL BADOX ERMOD GEM BULUT EZS PALUT UMLEN NAREN BAYIR BEYAZ CI641 VAKIT INKEL LTCI","planned_flight_time":0,"block_off_time":"2022-02-24T12:26:50.8104319Z","block_on_time":"2022-02-24T14:22:20.605988Z","flight_time":115,"block_fuel":21599.0,"fuel_used":12187.0,"landing_rate":-312.96,"score":90,"source_name":"vmsacars","fares":[{"id":1,"code":"Y","name":"Economy","type":0,"capacity":135,"count":116,"active":false},{"id":2,"code":"J","name":"Business","type":0,"capacity":16,"count":10,"active":false},{"id":4,"code":"CGO","name":"Cargo","type":1,"capacity":6000,"count":3840,"active":false}],"user":{"App\\Models\\User":{"id":106,"pilot_id":156,"airline_id":"1","rank_id":"4","country":"tr","home_airport_id":"LTFM","curr_airport_id":"LTCI","last_pirep_id":"9PplR7m2GZRQR1GZ","flights":4,"flight_time":363,"transfer_time":25778,"avatar":null,"timezone":"Europe/Istanbul","status":0,"state":1,"toc_accepted":true,"opt_in":false,"active":null,"created_at":"2022-02-20T18:14:22.000000Z","updated_at":"2022-02-24T14:22:22.000000Z","deleted_at":null}}} 
[2022-02-24 14:22:25] production.ERROR: App\Exceptions\PirepError: PIREP has already been submitted in /app/Services/PirepService.php:301
[2022-02-24 14:22:25] production.ERROR: API Error [{"file":"/app/Http/Controllers/Api/PirepController.php","line":308,"function":"file","class":"App\\Services\\PirepService","type":"->"}] 

Current ENUMS defined for Pirep > Status; https://github.com/nabeelio/phpvms/blob/dev/app/Models/Enums/PirepStatus.php#L14-L37

FatihKoz avatar Feb 24 '22 18:02 FatihKoz

Just an update, below are the results from my db

image

Looks like it will be nice to have a query running each night to fix these until a core/acars fix arrives ;)

FatihKoz avatar Sep 04 '22 14:09 FatihKoz

Hmm I forgot about this one, I'll try to take a look tomorrow

nabeelio avatar Sep 04 '22 15:09 nabeelio

Any updates ?

FatihKoz avatar Sep 25 '22 13:09 FatihKoz

Yeah I'm gonna fix this. Is it an actual double click or they click it once, pause a second and click out again?

nabeelio avatar Sep 25 '22 14:09 nabeelio

I have no idea, I tried double clicking to replicate.

FatihKoz avatar Sep 25 '22 15:09 FatihKoz

Have you seen this come up again?

nabeelio avatar Mar 18 '23 23:03 nabeelio

Yeah, unfortunately it is still happening with build 2369 of acars and latest dev build of phpvms v7. Latest occurrence was recorded today (19.MAR)

On Sun, Mar 19, 2023 at 2:28 AM Nabeel S. @.***> wrote:

Have you seen this come up again?

— Reply to this email directly, view it on GitHub https://github.com/nabeelio/phpvms/issues/1415#issuecomment-1475030037, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARXKVMIXJ6BTYENPYN45P4LW4ZALJANCNFSM5PIFNMUQ . You are receiving this because you authored the thread.Message ID: @.***>

FatihKoz avatar Mar 19 '23 15:03 FatihKoz