models

package
v1.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AllAircraftModels = 1
View Source
const AllTotals = 0
View Source
const JustLastModels = 2
View Source
const Last30Days = 30
View Source
const Last90Days = 90
View Source
const ThisMonth = 888
View Source
const ThisYear = 999

Variables

This section is empty.

Functions

func InitMock added in v1.3.0

func InitMock(mock sqlmock.Sqlmock)

InitMock is a common sqlmock init function which is used by tests in package models and main

Types

type Airport

type Airport struct {
	ICAO      string  `json:"icao"`
	IATA      string  `json:"iata"`
	Name      string  `json:"name"`
	City      string  `json:"city"`
	Country   string  `json:"country"`
	Elevation int     `json:"elevation"`
	Lat       float64 `json:"lat"`
	Lon       float64 `json:"lon"`
}

Airpot is a structure for airport record

type Attachment added in v1.4.0

type Attachment struct {
	UUID         string `json:"uuid"`
	RecordID     string `json:"record_id"`
	DocumentName string `json:"document_name"`
	Document     []byte
}

Attachment is a type for attachments

type ColumnsWidth added in v1.11.0

type ColumnsWidth struct {
	Col1  float64 `json:"col1"`
	Col2  float64 `json:"col2"`
	Col3  float64 `json:"col3"`
	Col4  float64 `json:"col4"`
	Col5  float64 `json:"col5"`
	Col6  float64 `json:"col6"`
	Col7  float64 `json:"col7"`
	Col8  float64 `json:"col8"`
	Col9  float64 `json:"col9"`
	Col10 float64 `json:"col10"`
	Col11 float64 `json:"col11"`
	Col12 float64 `json:"col12"`
	Col13 float64 `json:"col13"`
	Col14 float64 `json:"col14"`
	Col15 float64 `json:"col15"`
	Col16 float64 `json:"col16"`
	Col17 float64 `json:"col17"`
	Col18 float64 `json:"col18"`
	Col19 float64 `json:"col19"`
	Col20 float64 `json:"col20"`
	Col21 float64 `json:"col21"`
	Col22 float64 `json:"col22"`
	Col23 float64 `json:"col23"`
}

type DBModel

type DBModel struct {
	DB *sql.DB
}

DBModel is a type for database connections

func (*DBModel) Authenticate added in v1.10.0

func (m *DBModel) Authenticate(login, password string) error

Authenticate checks the credentials

func (*DBModel) CreateDistanceCache added in v1.3.0

func (m *DBModel) CreateDistanceCache()

CreateDistanceCache fills cache map with calculated distances

func (*DBModel) DeleteAttachment added in v1.4.0

func (m *DBModel) DeleteAttachment(uuid string) error

DeleteAttachment removes attachment record

func (*DBModel) DeleteAttachmentsForFlightRecord added in v1.4.0

func (m *DBModel) DeleteAttachmentsForFlightRecord(uuid string) error

func (*DBModel) DeleteFlightRecord

func (m *DBModel) DeleteFlightRecord(uuid string) error

DeleteFlightRecord deletes a flight record by UUID

func (*DBModel) DeleteLicenseAttachment added in v1.6.0

func (m *DBModel) DeleteLicenseAttachment(uuid string) error

DeleteLicenseAttachment drops license attachment

func (*DBModel) DeleteLicenseRecord

func (m *DBModel) DeleteLicenseRecord(uuid string) error

DeleteLicenseRecord deletes a license record by UUID

func (*DBModel) DisableAuthorization added in v1.10.0

func (m *DBModel) DisableAuthorization() error

DisableAuthorization reset the auth flag in the settings

func (*DBModel) GetAircraftModels

func (m *DBModel) GetAircraftModels(condition int) ([]string, error)

GetAircraftModels returns already recorded aircraft models

func (*DBModel) GetAircraftRegs

func (m *DBModel) GetAircraftRegs() ([]string, error)

GetAircraftRegs returns all already recorded aircraft registrations

func (*DBModel) GetAirportByID

func (m *DBModel) GetAirportByID(id string) (Airport, error)

GetAirportByID return airport record by ID (ICAO or IATA)

func (*DBModel) GetAirportCount

func (m *DBModel) GetAirportCount() (int, error)

GetAirportCount returns amount of records in the airports table

func (*DBModel) GetAirports

func (m *DBModel) GetAirports() (map[string]Airport, error)

GetAirports generates Airports DB for rendering maps

func (*DBModel) GetAttachmentByID added in v1.4.0

func (m *DBModel) GetAttachmentByID(uuid string) (Attachment, error)

GetAttachmentByID returns attachment record

func (*DBModel) GetAttachments added in v1.4.0

func (m *DBModel) GetAttachments(recordID string) ([]Attachment, error)

GetAttachments returns attachments array for a specific record_id

func (*DBModel) GetFlightRecordByID

func (m *DBModel) GetFlightRecordByID(uuid string) (FlightRecord, error)

GetFlightRecordByID returns flight record by UUID

func (*DBModel) GetFlightRecords

func (m *DBModel) GetFlightRecords() ([]FlightRecord, error)

GetFlightRecords returns the flight records in the logbook table

func (*DBModel) GetLicenseRecordByID

func (m *DBModel) GetLicenseRecordByID(uuid string) (License, error)

GetFlightRecordByID returns flight record by UUID

func (*DBModel) GetLicenses

func (m *DBModel) GetLicenses() ([]License, error)

GetFlightRecords returns the flight records in the logbook table

func (*DBModel) GetLicensesCategory

func (m *DBModel) GetLicensesCategory() ([]string, error)

GetLicensesCategory returns all already recorded categories

func (*DBModel) GetSettings

func (m *DBModel) GetSettings() (Settings, error)

GetSettings returns settings parameters

func (*DBModel) GetTotals

func (m *DBModel) GetTotals(days int) (FlightRecord, error)

GetTotals calculates totals

func (*DBModel) GetTotalsByAircraftClass added in v1.9.0

func (m *DBModel) GetTotalsByAircraftClass() (map[string]FlightRecord, error)

GetTotalsByAircraftClass calculates totals by aircraft class

func (*DBModel) GetTotalsByAircraftType

func (m *DBModel) GetTotalsByAircraftType() (map[string]FlightRecord, error)

GetTotalsByAircraftType calculates totals by aircraft type

func (*DBModel) GetTotalsByYear

func (m *DBModel) GetTotalsByYear() (map[string]FlightRecord, error)

GetTotalsByYear calculates totals by year

func (*DBModel) InsertAttachmentRecord added in v1.4.0

func (m *DBModel) InsertAttachmentRecord(att Attachment) error

InsertLicenseRecord add a new license record to the licensing table

func (*DBModel) InsertFlightRecord

func (m *DBModel) InsertFlightRecord(fr FlightRecord) error

InsertFlightRecord add a new flight record to the logbook table

func (*DBModel) InsertLicenseRecord

func (m *DBModel) InsertLicenseRecord(lic License) error

InsertLicenseRecord add a new license record to the licensing table

func (*DBModel) IsAuthEnabled added in v1.10.0

func (m *DBModel) IsAuthEnabled() bool

isAuthEnabled returns auth status

func (*DBModel) UpdateAirportDB

func (m *DBModel) UpdateAirportDB(airports []Airport) (int, error)

UpdateAirportDB updates airports table

func (*DBModel) UpdateFlightRecord

func (m *DBModel) UpdateFlightRecord(fr FlightRecord) error

UpdateFlightRecord updates the flight records in the logbook table

func (*DBModel) UpdateLicenseRecord

func (m *DBModel) UpdateLicenseRecord(lic License) error

UpdateLicenseRecord updates the license records in the licensing table

func (*DBModel) UpdateSettings

func (m *DBModel) UpdateSettings(settings Settings) error

UpdateSettings writes new settings values

type Export added in v1.11.0

type Export struct {
	LogbookRows int          `json:"logbook_rows"`
	Fill        int          `json:"fill"`
	LeftMargin  float64      `json:"left_margin"`
	LeftMarginA float64      `json:"left_margin_a"`
	LeftMarginB float64      `json:"left_margin_b"`
	TopMargin   float64      `json:"top_margin"`
	BodyRow     float64      `json:"body_row_height"`
	FooterRow   float64      `json:"footer_row_height"`
	PageBreaks  string       `json:"page_breaks"`
	Columns     ColumnsWidth `json:"columns"`
}

type FlightRecord

type FlightRecord struct {
	UUID      string `json:"uuid"`
	Date      string `json:"date"`
	MDate     string `json:"m_date"`
	Departure struct {
		Place string `json:"place"`
		Time  string `json:"time"`
	} `json:"departure"`
	Arrival struct {
		Place string `json:"place"`
		Time  string `json:"time"`
	} `json:"arrival"`
	Aircraft struct {
		Model string `json:"model"`
		Reg   string `json:"reg_name"`
	} `json:"aircraft"`
	Time struct {
		SE         string `json:"se_time"`
		ME         string `json:"me_time"`
		MCC        string `json:"mcc_time"`
		Total      string `json:"total_time"`
		Night      string `json:"night_time"`
		IFR        string `json:"ifr_time"`
		PIC        string `json:"pic_time"`
		CoPilot    string `json:"co_pilot_time"`
		Dual       string `json:"dual_time"`
		Instructor string `json:"instructor_time"`
	} `json:"time"`
	Landings struct {
		Day   int `json:"day"`
		Night int `json:"night"`
	} `json:"landings"`
	SIM struct {
		Type string `json:"type"`
		Time string `json:"time"`
	} `json:"sim"`
	PIC     string `json:"pic_name"`
	Remarks string `json:"remarks"`

	Distance int
}

FlightRecord is a type for logbook flight records

func CalculateTotals

func CalculateTotals(totals FlightRecord, record FlightRecord) FlightRecord

calculateTotals calculates totals for page footer

type JSONResponse

type JSONResponse struct {
	OK          bool   `json:"ok"`
	Message     string `json:"message,omitempty"`
	RedirectURL string `json:"redirect_url,omitempty"`
}

jsonResponse is a type for post data handlers response

type License

type License struct {
	UUID         string `json:"uuid"`
	Category     string `json:"category"`
	Name         string `json:"name"`
	Number       string `json:"number"`
	Issued       string `json:"issued"`
	ValidFrom    string `json:"valid_from"`
	ValidUntil   string `json:"valid_until"`
	DocumentName string `json:"document_name"`
	Document     []byte
}

License is a type for licesing

type Models

type Models struct {
	DB DBModel
}

Models is a wraper for DBModel

func NewModels

func NewModels(db *sql.DB) Models

NewMdels returns a model type with db connection pool

type Settings

type Settings struct {
	OwnerName       string            `json:"owner_name"`
	SignatureText   string            `json:"signature_text"`
	AircraftClasses map[string]string `json:"aircraft_classes"`
	AuthEnabled     bool              `json:"auth_enabled"`
	Login           string            `json:"login"`
	Password        string            `json:"password"`
	Hash            string            `json:"hash"`

	ExportA4 Export `json:"export_a4"`
	ExportA5 Export `json:"export_a5"`
}

Settings is a type for settings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址