package fmreport

import (
	"context"
	"errors"
)

var ErrDuplicateReportCode = errors.New("duplicate report code")

type ListFilter struct {
	Search               string
	FlightID             []byte
	TakeoverID           []byte
	FlightInspectionID   []byte
	FlightDate           string
	HasEngine1GpcN1      *bool
	HasEngine1PtcN2      *bool
	HasEngine2GpcN1      *bool
	HasEngine2PtcN2      *bool
	Sort                 string
	FromDate             string
	ToDate               string
	HelicopterIdentifier string
	PilotName            string
}

type Repository interface {
	Upsert(ctx context.Context, row *Report) error
	GetByFlightID(ctx context.Context, flightID []byte) (*Report, error)
	GetByID(ctx context.Context, id []byte) (*Report, error)
	MaxReportSeqByHelicopter(ctx context.Context, helicopterID []byte) (int, error)
	SetReportCode(ctx context.Context, id []byte, code string) error
	List(ctx context.Context, filter ListFilter, limit, offset int) ([]Report, int64, error)
	Delete(ctx context.Context, id, deletedBy []byte) error
	CreateFleetHistory(ctx context.Context, row *FleetHistory) error
	GetFleetHistoryByReportID(ctx context.Context, reportID []byte) (*FleetHistory, error)
}
