Skip to content

Commit

Permalink
Merge pull request #62 from cmeyer18/deprecate
Browse files Browse the repository at this point in the history
Deprecated!
  • Loading branch information
cmeyer18 committed May 25, 2024
2 parents 8619779 + a5b9efc commit 95d893f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data_structures/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"github.com/cmeyer18/weather-common/v4/data_structures/geojson"
)

// Deprecated: use AlertV2
type Alert struct {
ID string `json:"id"`
Type string `json:"type"`
Geometry *geojson.Geometry `json:"geometry"`
Properties AlertProperties `json:"properties"`
}

// Deprecated: use AlertV2
type AlertProperties struct {
AtID string `json:"@id"`
Type string `json:"@type"`
Expand Down Expand Up @@ -42,11 +44,13 @@ type AlertProperties struct {
Parameters AlertPropertiesParameters `json:"parameters"`
}

// Deprecated: use AlertV2
type AlertPropertiesGeocode struct {
SAME []string `json:"SAME"`
UGC []string `json:"UGC"`
}

// Deprecated: use AlertV2
type AlertPropertiesParameters struct {
AWIPSIdentifier []string `json:"AWIPSidentifier"`
WMOIdentifier []string `json:"WMOidentifier"`
Expand All @@ -56,6 +60,7 @@ type AlertPropertiesParameters struct {
ExpiredReferences []string `json:"expiredReferences"`
}

// Deprecated: use AlertV2
type AlertPropertiesReferences struct {
AtID string `json:"@id"`
Identifier string `json:"identifier"`
Expand Down
3 changes: 3 additions & 0 deletions data_structures/convective_outlook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ import (
"github.com/cmeyer18/weather-common/v4/generative/golang"
)

// Deprecated: use ConvectiveOutlookV2
type ConvectiveOutlook struct {
Type string `json:"type"`
PublishedTime time.Time `json:"publishedTime"`
OutlookType golang.ConvectiveOutlookType `json:"outlookType"`
Features []ConvectiveOutlookFeature `json:"features"`
}

// Deprecated: use ConvectiveOutlookV2
type ConvectiveOutlookFeature struct {
Type string `json:"type"`
Geometry *geojson.Geometry `json:"geometry"`
Properties ConvectiveOutlookFeatureProperties `json:"properties"`
}

// Deprecated: use ConvectiveOutlookV2
type ConvectiveOutlookFeatureProperties struct {
DN int `json:"DN"`
Valid time.Time `json:"VALID"`
Expand Down
1 change: 1 addition & 0 deletions data_structures/geojson/geometry.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package geojson

// Deprecated: use GeometryV2
type Geometry struct {
Type string `json:"type"`
Polygon *Polygon `json:"Polygon,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions data_structures/geojson/multipoint.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package geojson

// Deprecated: use MultiPointV2
type MultiPoint struct {
Points []*Point `json:"points,omitempty"`
}
1 change: 1 addition & 0 deletions data_structures/geojson/point.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package geojson

// Deprecated: use PointV2
type Point struct {
Latitude float64 `json:"lat"`
Longitude float64 `json:"lon"`
Expand Down
3 changes: 3 additions & 0 deletions data_structures/geojson/polygon.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package geojson

// Deprecated: use PolygonV2, not using go based location parsing
type Polygon struct {
OuterPath *MultiPoint `json:"outerPath"`
InnerPaths []*MultiPoint `json:"innerPaths,omitempty"`
}

// Deprecated:
func NewPolygonShape(outerPath *MultiPoint, innerPaths []*MultiPoint) *Polygon {
return &Polygon{OuterPath: outerPath, InnerPaths: innerPaths}
}

// Deprecated:
func (p *Polygon) ContainsPoint(point *Point) bool {
return p.containedInOuterPath(point) && !p.containedInInnerPaths(point)
}
Expand Down
1 change: 1 addition & 0 deletions data_structures/mesoscale_discussion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package data_structures

import "github.com/cmeyer18/weather-common/v4/data_structures/geojson"

// Deprecated: use MesoscaleDiscussionV2
type MesoscaleDiscussion struct {
MDNumber int
Year int
Expand Down
1 change: 1 addition & 0 deletions data_structures/server_notification_update.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package data_structures

// Deprecated: use NotificationUpdateV2
type NotificationUpdate struct {
Alert *Alert `json:"alert,omitempty"`
ConvectiveOutlook *ConvectiveOutlook `json:"convectiveOutlook,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions sql/alert_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

var _ IAlertTable = (*PostgresAlertTable)(nil)

// Deprecated: use IAlertTableV2
type IAlertTable interface {
common_tables.IIdTable[data_structures.Alert]

Expand All @@ -25,16 +26,19 @@ type IAlertTable interface {
Exists(id string) (bool, error)
}

// Deprecated: use PostgresAlertTableV2
type PostgresAlertTable struct {
db *sql.DB
}

// Deprecated: use NewPostgresAlertTableV2
func NewPostgresAlertTable(db *sql.DB) PostgresAlertTable {
return PostgresAlertTable{
db: db,
}
}

// Deprecated:
func (p *PostgresAlertTable) Insert(alert data_structures.Alert) error {
//language=SQL
query := `INSERT INTO alerts (id, payload) VALUES ($1, $2)`
Expand All @@ -52,6 +56,7 @@ func (p *PostgresAlertTable) Insert(alert data_structures.Alert) error {
return nil
}

// Deprecated:
func (p *PostgresAlertTable) Select(id string) (*data_structures.Alert, error) {
query := `SELECT payload FROM alerts WHERE id = $1`

Expand All @@ -71,6 +76,7 @@ func (p *PostgresAlertTable) Select(id string) (*data_structures.Alert, error) {
return &alert, nil
}

// Deprecated:
func (p *PostgresAlertTable) SelectAlertsByCode(codes []string) ([]data_structures.Alert, error) {
query := `
SELECT payload
Expand Down Expand Up @@ -111,6 +117,7 @@ func (p *PostgresAlertTable) SelectAlertsByCode(codes []string) ([]data_structur
return alerts, nil
}

// Deprecated:
func (p *PostgresAlertTable) Exists(id string) (bool, error) {
query := `SELECT count(id) FROM alerts WHERE id = $1`

Expand All @@ -129,6 +136,7 @@ func (p *PostgresAlertTable) Exists(id string) (bool, error) {
return false, nil
}

// Deprecated:
func (p *PostgresAlertTable) Delete(id string) error {
query := `DELETE FROM alerts WHERE id = $1`

Expand All @@ -149,6 +157,7 @@ func (p *PostgresAlertTable) Delete(id string) error {
return nil
}

// Deprecated:
func (p *PostgresAlertTable) DeleteExpiredAlerts(id string) error {
query := `DELETE FROM alerts WHERE id = $1`

Expand Down
6 changes: 6 additions & 0 deletions sql/convective_outlook_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

var _ IConvectiveOutlookTable = (*PostgresConvectiveOutlookTable)(nil)

// Deprecated: use IConvectiveOutlookTableV2
type IConvectiveOutlookTable interface {
Insert(outlook data_structures.ConvectiveOutlook) error

Expand All @@ -20,16 +21,19 @@ type IConvectiveOutlookTable interface {
SelectLatest(outlookType golang.ConvectiveOutlookType) (*data_structures.ConvectiveOutlook, error)
}

// Deprecated: use PostgresConvectiveOutlookTableV2
type PostgresConvectiveOutlookTable struct {
db *sql.DB
}

// Deprecated: use NewPostgresConvectiveOutlookTableV2
func NewPostgresConvectiveOutlookTable(db *sql.DB) PostgresConvectiveOutlookTable {
return PostgresConvectiveOutlookTable{
db: db,
}
}

// Deprecated:
func (p *PostgresConvectiveOutlookTable) Insert(outlook data_structures.ConvectiveOutlook) error {
//language=SQL
query := `INSERT INTO convectiveOutlookTable (outlookType, outlook) VALUES ($1, $2)`
Expand All @@ -46,6 +50,7 @@ func (p *PostgresConvectiveOutlookTable) Insert(outlook data_structures.Convecti
return nil
}

// Deprecated:
func (p *PostgresConvectiveOutlookTable) Select(publishedTime time.Time, outlookType golang.ConvectiveOutlookType) (*data_structures.ConvectiveOutlook, error) {
query := `SELECT outlook FROM convectiveOutlookTable WHERE outlookType = $1`

Expand All @@ -68,6 +73,7 @@ func (p *PostgresConvectiveOutlookTable) Select(publishedTime time.Time, outlook
return &outlook, nil
}

// Deprecated:
func (p *PostgresConvectiveOutlookTable) SelectLatest(outlookType golang.ConvectiveOutlookType) (*data_structures.ConvectiveOutlook, error) {
query := `SELECT outlook FROM convectiveOutlookTable WHERE outlooktype = $1 ORDER BY (outlook->'features'->0->'properties'->>'VALID')::timestamptz DESC LIMIT 1`

Expand Down
7 changes: 7 additions & 0 deletions sql/mesoscale_discussion_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

var _ IPostgresMesoscaleDiscussionTable = (*PostgresMesoscaleDiscussionTable)(nil)

// Deprecated: use IPostgresMesoscaleDiscussionTableV2
type IPostgresMesoscaleDiscussionTable interface {
Insert(md data_structures.MesoscaleDiscussion) error

Expand All @@ -20,16 +21,19 @@ type IPostgresMesoscaleDiscussionTable interface {
SelectMDNotInTable(year int, mdsToCheck map[int]bool) ([]int, error)
}

// Deprecated: use PostgresMesoscaleDiscussionTableV2
type PostgresMesoscaleDiscussionTable struct {
db *sql.DB
}

// Deprecated: use NewPostgresMesoscaleDicussionTableV2
func NewPostgresMesoscaleDicussionTable(db *sql.DB) PostgresMesoscaleDiscussionTable {
return PostgresMesoscaleDiscussionTable{
db: db,
}
}

// Deprecated:
func (p *PostgresMesoscaleDiscussionTable) Insert(md data_structures.MesoscaleDiscussion) error {
//language=SQL
query := `INSERT INTO mesoscaleDiscussion (mdNumber, year, affectedArea, rawText) VALUES ($1, $2, $3, $4)`
Expand All @@ -47,6 +51,7 @@ func (p *PostgresMesoscaleDiscussionTable) Insert(md data_structures.MesoscaleDi
return nil
}

// Deprecated:
func (p *PostgresMesoscaleDiscussionTable) Select(year, mdNumber int) (*data_structures.MesoscaleDiscussion, error) {
query := `SELECT mdNumber, year, affectedArea, rawText FROM mesoscaleDiscussion WHERE year = $1 AND mdNumber = $2`

Expand Down Expand Up @@ -76,6 +81,7 @@ func (p *PostgresMesoscaleDiscussionTable) Select(year, mdNumber int) (*data_str
return &md, nil
}

// Deprecated:
func (p *PostgresMesoscaleDiscussionTable) SelectMDNotInTable(year int, mdsToCheck map[int]bool) ([]int, error) {
query := `SELECT mdNumber FROM mesoscaleDiscussion WHERE year = $1`

Expand Down Expand Up @@ -104,6 +110,7 @@ func (p *PostgresMesoscaleDiscussionTable) SelectMDNotInTable(year int, mdsToChe
return mdsNotInTable, nil
}

// Deprecated:
func (p *PostgresMesoscaleDiscussionTable) Delete(year, mdNumber int) error {
query := `DELETE FROM mesoscaleDiscussion WHERE year = $1 AND mdNumber = $2`

Expand Down

0 comments on commit 95d893f

Please sign in to comment.