sqlite

package
v0.0.0-...-8b2c356 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROACTIVE = "ProactiveEmailAlert"
	REACTIVE  = "ReactiveEmailAlert"
)

internal conts

Variables

This section is empty.

Functions

func CheckAlertTable

func CheckAlertTable(db *sql.DB, alert string) time.Time

CheckAlertTable utility function to check for a specific alert type the last_date sent a bit like a NOSQL case squeezed int sqlite... :-/

func Close

func Close(db *sql.DB)

func DeleteComment

func DeleteComment(db *sql.DB, comment Comment)

func FormatIfNotEmpty

func FormatIfNotEmpty(anullTime null.Time) string

func InitDB

func InitDB(db *sql.DB)

func InsertComuni

func InsertComuni(db *sql.DB, comuni []Comune)

func InsertFornitori

func InsertFornitori(db *sql.DB, fornitori []Fornitore)

func IntValue

func IntValue(t null.Time) *int64

func IsPresent

func IsPresent(db *sql.DB, sqlSelect string) bool

func OpenDB

func OpenDB(dbName string) *sql.DB

func SaveOrUpdateComment

func SaveOrUpdateComment(db *sql.DB, comment Comment)

func SaveOrUpdateLastUpdate

func SaveOrUpdateLastUpdate(db *sql.DB, time int64)

func SaveOrUpdateSubentro

func SaveOrUpdateSubentro(db *sql.DB, comune Comune)

func TimeStampOrNull

func TimeStampOrNull(time null.Time) null.Int

func UpdateAlertsTable

func UpdateAlertsTable(db *sql.DB, alert string)

UpdateAlertsTable utility function to update the last_date of an executed process a bit like a NOSQL case squeezed int sqlite... :-/

func UpdateAnomalieSchedeSoggettoDate

func UpdateAnomalieSchedeSoggettoDate(db *sql.DB, anomalie []Anomalie)

func UpdateComuneCheckListDate

func UpdateComuneCheckListDate(db *sql.DB, comuni []Comune)

func UpdateComuneFornitore

func UpdateComuneFornitore(db *sql.DB, codiceIstat string, fornitore int)

* Update the association between a comune and a fornitore

Types

type Alerting

type Alerting struct {
	Name           string
	FornitoreName  string
	FornitoreEmail string
	DateFrom       string
	DateTo         string
}

func SearchAlerts

func SearchAlerts(db *sql.DB, alertType string) []Alerting

SearchAlert : SQL extract logic to get the alerts to be sent to SWH for multiple cases ANPR-80 (refactored ANPR-79 code)

type Anomalie

type Anomalie struct {
	Description   string
	CodiceIstat   string
	Name          string
	Population    int
	Code          string
	Number        int
	ClassAnomalia string
	TipoAnomalia  string
}

func SearchAnomalie

func SearchAnomalie(db *sql.DB, searchFilter AnomalieSearchFilter) []Anomalie

type AnomalieSearchFilter

type AnomalieSearchFilter struct {
	CodiceIstat string     `json:"CodiceIstat"`
	Order       *Order     `json:"order"`
	Exclusion   *Exclusion `json:"exclusion"`
}

type Comment

type Comment struct {
	Id      int
	Comune  Comune
	Date    null.Time
	Author  string
	Content string
}

func SearchComment

func SearchComment(db *sql.DB, comune Comune) []Comment

to avoid to resend mails on reloads

func (*Comment) AsString

func (c *Comment) AsString() string

type Comune

type Comune struct {
	Id          int
	CodiceIstat string
	Name        string
	Region      string // Non esistente in schede monitoraggio.
	Province    string

	Population             int
	PopulationAIRE         int
	Postazioni             null.Int
	Lat                    float64
	Lon                    float64
	Fornitore              Fornitore
	Responsible            Responsible `json:"-"`
	Indirizzo              Indirizzo   `json:"-"`
	Subentro               Subentro
	DataSubentro           null.Time
	DataAbilitazione       null.Time
	DataPresubentro        null.Time
	AbilitazionePrefettura null.Bool
	UtentiAbilitati        null.Int
	DataConsegnaSm         null.Time
	NumeroLettori          null.Int
	IPProvenienza          null.Bool
	EmailPec               null.Bool
	SCConsegnate           null.Int
	DataRitiroSm           null.Time
	DataPrimoPresubentro   null.Time

	DataCessazione   null.Time
	TipoCessazione   null.String
	ComuneConfluenza null.String
}

A base structure for Comune including basic contact information

func NewComuneFromCSVRecord

func NewComuneFromCSVRecord(csv_record []string) (*Comune, error)

func SearchComuni

func SearchComuni(db *sql.DB, searchFilter SearchFilter) []Comune

func (*Comune) AsCSVRecord

func (c *Comune) AsCSVRecord() []string

func (*Comune) AsCSVRecordForNotify

func (c *Comune) AsCSVRecordForNotify() []string

func (*Comune) AsDetailedCSVRecord

func (c *Comune) AsDetailedCSVRecord() []string

func (*Comune) ToComuneInfo

func (c *Comune) ToComuneInfo() ComuneInfo

Convert a Comune into ComuneInfo holding just the information needed in order to show at the frontend

type ComuneFornitore

type ComuneFornitore struct {
	CodiceIstat string `json:"CodiceIstat"`
	FornitoreID int    `json:"FornitoreId"`
}

type ComuneInfo

type ComuneInfo struct {
	CodiceIstat                      string
	Name                             string
	DataSubentro                     null.Time
	DataAbilitazione                 null.Time
	DataPresubentro                  null.Time
	PianificazioneIntervalloSubentro Subentro
}

Holds just the basic information about a Comue

type Exclusion

type Exclusion struct {
	ExclusionType ExclusionType
}

type ExclusionType

type ExclusionType int
const (
	ExcludeWithoutFinalDate ExclusionType = iota
	ExcludeWithoutSubentro
	ExcludeAlreadyWithSubentro
	ExcludeInactive
)

type Fornitore

type Fornitore struct {
	Id    int `json:"id"`
	Name  string
	Url   string
	EMail string
}

type Indirizzo

type Indirizzo struct {
	Via    string
	Cap    string
	Civico string
	Pec    string
}

type LastUpdate

type LastUpdate struct {
	Timestamp int64 `json:"timestamp"`
}

func GetLastUpdate

func GetLastUpdate(db *sql.DB) LastUpdate

type Order

type Order struct {
	OrderType OrderType
}

type OrderType

type OrderType int
const (
	FornitoreName OrderType = iota
	DateFinal
	Population
	SubentroFrom
	DatePresubentro
	DataSubentro
)

type Responsible

type Responsible struct {
	Name    string
	Surname string
	Phone   string
	Mobile  string
	Email   string
}

type SearchFilter

type SearchFilter struct {
	Fornitore Fornitore  `json:"fornitore"`
	Comune    Comune     `json:"comune"`
	Order     *Order     `json:"order"`
	Exclusion *Exclusion `json:"exclusion"`
}

type Subentro

type Subentro struct {
	From          null.Time
	To            null.Time
	PreferredDate null.Time
	IP            null.String
}

func (*Subentro) HasValidDates

func (s *Subentro) HasValidDates() bool

HasValidDates one date is valid

func (*Subentro) IsWellFormed

func (s *Subentro) IsWellFormed(comune *Comune) (bool, error)

IsWellFormed if the date interval is consitent

type SubentroInfo

type SubentroInfo struct {
	DateFinal  null.Time
	Comuni     null.Int
	Population null.Int
}

func GetSubentroInfo

func GetSubentroInfo(db *sql.DB, aDate null.Time) SubentroInfo

Jump to

Keyboard shortcuts

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