invernyx / smartcars-3-phpvms5-api

The API responsible for connecting smartCARS to phpVMS 5
MIT License
7 stars 7 forks source link

[BUG] - Cancelling a flight leaves an unfinished pirep in phpvms which breaks the logbook #67

Closed Thien42 closed 1 year ago

Thien42 commented 1 year ago

Describe the bug

In phpvms7, ongoing flights seem to create an incomplete pirep object with status pending which doesn't get deleted on cancellation. This pirep also had a missing aircraft_id which breaks the logbook.

How do you reproduce this bug?

  1. Bid on a flight in a phpvms7 instance
  2. Start the flight
  3. Cancel mid-flight
  4. Observe a stale pirep object still being present in the database

Expected behavior

The pirep object gets deleted on flight cancellation by the user

Screenshots

No response

API Version

0.3.3

PHP Version

8

Database & version

Mysql

Webserver version

Apache 2

Browser

Any

Handler

Any

Additional context

No response

GenericNerd commented 1 year ago

Related to #60. This will be resolved by adding a /flight/cancel to cancel an ongoing flight which will delete the data in the ongoing flights tables and also remove a PIREP in phpVMS 7

BossOfGames commented 1 year ago

Related to #60. This will be resolved by adding a /flight/cancel to cancel an ongoing flight which will delete the data in the ongoing flights tables and also remove a PIREP in phpVMS 7

I would advise to use the phpVMS specific PIREP state and not delete the PIREP. This would solve the problem, and, keep it native to phpVMS 7 when a VA is running both vmsACARS and smartCARS 3.

class PirepState extends Enum
{
    public const IN_PROGRESS = 0;  // flight is ongoing
    public const PENDING = 1;  // waiting admin approval
    public const ACCEPTED = 2;
    public const CANCELLED = 3;
    public const DELETED = 4;
    public const DRAFT = 5;
    public const REJECTED = 6;
    public const PAUSED = 7;

    protected static array $labels = [
        self::IN_PROGRESS => 'pireps.state.in_progress',
        self::PENDING     => 'pireps.state.pending',
        self::ACCEPTED    => 'pireps.state.accepted',
        self::CANCELLED   => 'pireps.state.cancelled',
        self::DELETED     => 'pireps.state.deleted',
        self::DRAFT       => 'pireps.state.draft',
        self::REJECTED    => 'pireps.state.rejected',
        self::PAUSED      => 'pireps.state.paused',
    ];
}
GenericNerd commented 1 year ago

Resolved in 0.3.5