Fix MustGet calls from when Globalid was not required.
This commit is contained in:
parent
c6b048d0cb
commit
2e74f95e8c
2 changed files with 48 additions and 48 deletions
4
html.go
4
html.go
|
|
@ -766,7 +766,7 @@ func trapsBySource(ctx context.Context, org *models.Organization, sourceID uuid.
|
||||||
location_ids := make([]uuid.UUID, 0)
|
location_ids := make([]uuid.UUID, 0)
|
||||||
var args []bob.Expression
|
var args []bob.Expression
|
||||||
for _, location := range locations {
|
for _, location := range locations {
|
||||||
location_ids = append(location_ids, location.TrapLocationGlobalid.MustGet())
|
location_ids = append(location_ids, location.TrapLocationGlobalid)
|
||||||
args = append(args, psql.Arg(location.TrapLocationGlobalid))
|
args = append(args, psql.Arg(location.TrapLocationGlobalid))
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -944,7 +944,7 @@ func breedingSourcesByCell(ctx context.Context, org *models.Organization, c h3.C
|
||||||
last_treat_date = &l
|
last_treat_date = &l
|
||||||
}
|
}
|
||||||
results = append(results, BreedingSourceSummary{
|
results = append(results, BreedingSourceSummary{
|
||||||
ID: r.Globalid.MustGet(),
|
ID: r.Globalid,
|
||||||
LastInspected: last_inspected,
|
LastInspected: last_inspected,
|
||||||
LastTreated: last_treat_date,
|
LastTreated: last_treat_date,
|
||||||
Type: r.Habitat.GetOr("none"),
|
Type: r.Habitat.GetOr("none"),
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ import (
|
||||||
|
|
||||||
type BreedingSourceDetail struct {
|
type BreedingSourceDetail struct {
|
||||||
// Basic Information
|
// Basic Information
|
||||||
OrganizationID int32 `json:"organizationId"`
|
OrganizationID int32 `json:"organizationId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
LocationNumber int64 `json:"locationNumber"`
|
LocationNumber int64 `json:"locationNumber"`
|
||||||
ObjectID int64 `json:"objectId"`
|
ObjectID int64 `json:"objectId"`
|
||||||
GlobalID uuid.UUID `json:"globalId"`
|
GlobalID uuid.UUID `json:"globalId"`
|
||||||
ExternalID string `json:"externalId"`
|
ExternalID string `json:"externalId"`
|
||||||
|
|
||||||
// Status Information
|
// Status Information
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
|
|
@ -45,35 +45,35 @@ type BreedingSourceDetail struct {
|
||||||
AccessDescription string `json:"accessDescription"`
|
AccessDescription string `json:"accessDescription"`
|
||||||
|
|
||||||
// Inspection Data
|
// Inspection Data
|
||||||
LarvaeInspectInterval int16 `json:"larvaeInspectInterval"`
|
LarvaeInspectInterval int16 `json:"larvaeInspectInterval"`
|
||||||
LastInspectionDate *time.Time `json:"lastInspectionDate"`
|
LastInspectionDate *time.Time `json:"lastInspectionDate"`
|
||||||
LastInspectionActivity string `json:"lastInspectionActivity"`
|
LastInspectionActivity string `json:"lastInspectionActivity"`
|
||||||
LastInspectionActionTaken string `json:"lastInspectionActionTaken"`
|
LastInspectionActionTaken string `json:"lastInspectionActionTaken"`
|
||||||
LastInspectionAverageLarvae float64 `json:"lastInspectionAverageLarvae"`
|
LastInspectionAverageLarvae float64 `json:"lastInspectionAverageLarvae"`
|
||||||
LastInspectionAveragePupae float64 `json:"lastInspectionAveragePupae"`
|
LastInspectionAveragePupae float64 `json:"lastInspectionAveragePupae"`
|
||||||
LastInspectionBreeding string `json:"lastInspectionBreeding"`
|
LastInspectionBreeding string `json:"lastInspectionBreeding"`
|
||||||
LastInspectionConditions string `json:"lastInspectionConditions"`
|
LastInspectionConditions string `json:"lastInspectionConditions"`
|
||||||
LastInspectionFieldSpecies string `json:"lastInspectionFieldSpecies"`
|
LastInspectionFieldSpecies string `json:"lastInspectionFieldSpecies"`
|
||||||
LastInspectionLifeStages string `json:"lastInspectionLifeStages"`
|
LastInspectionLifeStages string `json:"lastInspectionLifeStages"`
|
||||||
|
|
||||||
// Treatment Data
|
// Treatment Data
|
||||||
LastTreatmentDate *time.Time `json:"lastTreatmentDate"`
|
LastTreatmentDate *time.Time `json:"lastTreatmentDate"`
|
||||||
LastTreatmentActivity string `json:"lastTreatmentActivity"`
|
LastTreatmentActivity string `json:"lastTreatmentActivity"`
|
||||||
LastTreatmentProduct string `json:"lastTreatmentProduct"`
|
LastTreatmentProduct string `json:"lastTreatmentProduct"`
|
||||||
LastTreatmentQuantity float64 `json:"lastTreatmentQuantity"`
|
LastTreatmentQuantity float64 `json:"lastTreatmentQuantity"`
|
||||||
LastTreatmentQuantityUnit string `json:"lastTreatmentQuantityUnit"`
|
LastTreatmentQuantityUnit string `json:"lastTreatmentQuantityUnit"`
|
||||||
|
|
||||||
// Assignment & Schedule
|
// Assignment & Schedule
|
||||||
AssignedTechnician string `json:"assignedTechnician"`
|
AssignedTechnician string `json:"assignedTechnician"`
|
||||||
NextActionScheduledDate *time.Time `json:"nextActionScheduledDate"`
|
NextActionScheduledDate *time.Time `json:"nextActionScheduledDate"`
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
Created *time.Time `json:"created"`
|
Created *time.Time `json:"created"`
|
||||||
Creator string `json:"creator"`
|
Creator string `json:"creator"`
|
||||||
EditedAt *time.Time `json:"editedAt"`
|
EditedAt *time.Time `json:"editedAt"`
|
||||||
Editor string `json:"editor"`
|
Editor string `json:"editor"`
|
||||||
//Updated *time.Time `json:"updated"`
|
//Updated *time.Time `json:"updated"`
|
||||||
Comments string `json:"comments"`
|
Comments string `json:"comments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrapNearby struct {
|
type TrapNearby struct {
|
||||||
|
|
@ -92,13 +92,13 @@ type TrapCount struct {
|
||||||
|
|
||||||
type TrapData struct {
|
type TrapData struct {
|
||||||
// Basic Identifiers
|
// Basic Identifiers
|
||||||
OrganizationID int32 `json:"organizationId"`
|
OrganizationID int32 `json:"organizationId"`
|
||||||
ObjectID int64 `json:"objectId"`
|
ObjectID int64 `json:"objectId"`
|
||||||
GlobalID uuid.UUID `json:"globalId"`
|
GlobalID uuid.UUID `json:"globalId"`
|
||||||
LocationName string `json:"locationName"`
|
LocationName string `json:"locationName"`
|
||||||
LocationID uuid.UUID `json:"locationId"`
|
LocationID uuid.UUID `json:"locationId"`
|
||||||
SRID uuid.UUID `json:"srid"`
|
SRID uuid.UUID `json:"srid"`
|
||||||
Field int64 `json:"field"`
|
Field int64 `json:"field"`
|
||||||
|
|
||||||
// Trap Information
|
// Trap Information
|
||||||
TrapType string `json:"trapType"`
|
TrapType string `json:"trapType"`
|
||||||
|
|
@ -124,14 +124,14 @@ type TrapData struct {
|
||||||
SiteCondition string `json:"siteCondition"`
|
SiteCondition string `json:"siteCondition"`
|
||||||
|
|
||||||
// Status and Processing
|
// Status and Processing
|
||||||
Processed bool `json:"processed"`
|
Processed bool `json:"processed"`
|
||||||
RecordStatus int16 `json:"recordStatus"`
|
RecordStatus int16 `json:"recordStatus"`
|
||||||
Reviewed bool `json:"reviewed"`
|
Reviewed bool `json:"reviewed"`
|
||||||
ReviewedBy string `json:"reviewedBy"`
|
ReviewedBy string `json:"reviewedBy"`
|
||||||
ReviewedDate *time.Time `json:"reviewedDate"`
|
ReviewedDate *time.Time `json:"reviewedDate"`
|
||||||
GatewaySynced bool `json:"gatewaySynced"`
|
GatewaySynced bool `json:"gatewaySynced"`
|
||||||
LR bool `json:"laboratoryReported"`
|
LR bool `json:"laboratoryReported"`
|
||||||
Voltage float64 `json:"voltage"`
|
Voltage float64 `json:"voltage"`
|
||||||
|
|
||||||
// Location Data
|
// Location Data
|
||||||
GeometryX float64 `json:"geometryX"`
|
GeometryX float64 `json:"geometryX"`
|
||||||
|
|
@ -145,15 +145,15 @@ type TrapData struct {
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
Created *time.Time `json:"created"`
|
Created *time.Time `json:"created"`
|
||||||
Creator string `json:"creator"`
|
Creator string `json:"creator"`
|
||||||
CreatedByUser string `json:"createdByUser"`
|
CreatedByUser string `json:"createdByUser"`
|
||||||
CreatedDateAlt *time.Time `json:"createdDateAlt"`
|
CreatedDateAlt *time.Time `json:"createdDateAlt"`
|
||||||
Edited *time.Time `json:"edited"`
|
Edited *time.Time `json:"edited"`
|
||||||
Editor string `json:"editor"`
|
Editor string `json:"editor"`
|
||||||
LastEditedDate *time.Time `json:"lastEditedDate"`
|
LastEditedDate *time.Time `json:"lastEditedDate"`
|
||||||
LastEditedUser string `json:"lastEditedUser"`
|
LastEditedUser string `json:"lastEditedUser"`
|
||||||
//Updated *time.Time `json:"updated"`
|
//Updated *time.Time `json:"updated"`
|
||||||
Comments string `json:"comments"`
|
Comments string `json:"comments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Treatment struct {
|
type Treatment struct {
|
||||||
|
|
@ -168,7 +168,7 @@ func toTemplateTraps(locations []sql.TrapLocationBySourceIDRow, trap_data []sql.
|
||||||
results := make([]TrapNearby, 0)
|
results := make([]TrapNearby, 0)
|
||||||
count_by_trap_data_id := make(map[uuid.UUID]*sql.TrapCountByLocationIDRow)
|
count_by_trap_data_id := make(map[uuid.UUID]*sql.TrapCountByLocationIDRow)
|
||||||
for _, c := range counts {
|
for _, c := range counts {
|
||||||
count_by_trap_data_id[c.TrapdataGlobalid.MustGet()] = &c
|
count_by_trap_data_id[c.TrapdataGlobalid] = &c
|
||||||
}
|
}
|
||||||
counts_by_location_id := make(map[uuid.UUID][]*TrapCount)
|
counts_by_location_id := make(map[uuid.UUID][]*TrapCount)
|
||||||
for _, td := range trap_data {
|
for _, td := range trap_data {
|
||||||
|
|
@ -193,14 +193,14 @@ func toTemplateTraps(locations []sql.TrapLocationBySourceIDRow, trap_data []sql.
|
||||||
counts_by_location_id[loc_id] = counts
|
counts_by_location_id[loc_id] = counts
|
||||||
}
|
}
|
||||||
for _, location := range locations {
|
for _, location := range locations {
|
||||||
counts, ok := counts_by_location_id[location.TrapLocationGlobalid.MustGet()]
|
counts, ok := counts_by_location_id[location.TrapLocationGlobalid]
|
||||||
if !ok {
|
if !ok {
|
||||||
return results, errors.New(fmt.Sprintf("Failed to find counts for %s", location.TrapLocationGlobalid))
|
return results, errors.New(fmt.Sprintf("Failed to find counts for %s", location.TrapLocationGlobalid))
|
||||||
}
|
}
|
||||||
trap := TrapNearby{
|
trap := TrapNearby{
|
||||||
Counts: counts,
|
Counts: counts,
|
||||||
Distance: location.Distance,
|
Distance: location.Distance,
|
||||||
ID: location.TrapLocationGlobalid.MustGet(),
|
ID: location.TrapLocationGlobalid,
|
||||||
}
|
}
|
||||||
results = append(results, trap)
|
results = append(results, trap)
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +219,7 @@ func toTemplateTrapData(trap_data models.FieldseekerTrapdatumSlice) ([]TrapData,
|
||||||
// Basic Identifiers
|
// Basic Identifiers
|
||||||
OrganizationID: r.OrganizationID,
|
OrganizationID: r.OrganizationID,
|
||||||
ObjectID: r.Objectid,
|
ObjectID: r.Objectid,
|
||||||
GlobalID: r.Globalid.MustGet(),
|
GlobalID: r.Globalid,
|
||||||
LocationName: r.Locationname.GetOr(""),
|
LocationName: r.Locationname.GetOr(""),
|
||||||
LocationID: r.LocID.GetOr(uuid.UUID{}),
|
LocationID: r.LocID.GetOr(uuid.UUID{}),
|
||||||
SRID: r.Srid.GetOr(uuid.UUID{}),
|
SRID: r.Srid.GetOr(uuid.UUID{}),
|
||||||
|
|
@ -278,7 +278,7 @@ func toTemplateTrapData(trap_data models.FieldseekerTrapdatumSlice) ([]TrapData,
|
||||||
LastEditedDate: getTimeOrNull(r.LastEditedDate),
|
LastEditedDate: getTimeOrNull(r.LastEditedDate),
|
||||||
LastEditedUser: r.LastEditedUser.GetOr(""),
|
LastEditedUser: r.LastEditedUser.GetOr(""),
|
||||||
//Updated: r.Updated,
|
//Updated: r.Updated,
|
||||||
Comments: r.Comments.GetOr(""),
|
Comments: r.Comments.GetOr(""),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, nil
|
||||||
|
|
@ -343,7 +343,7 @@ func toTemplateBreedingSource(source *models.FieldseekerPointlocation) *Breeding
|
||||||
Description: source.Description.MustGet(),
|
Description: source.Description.MustGet(),
|
||||||
LocationNumber: int64(source.Locationnumber.GetOr(0)),
|
LocationNumber: int64(source.Locationnumber.GetOr(0)),
|
||||||
ObjectID: source.Objectid,
|
ObjectID: source.Objectid,
|
||||||
GlobalID: source.Globalid.MustGet(),
|
GlobalID: source.Globalid,
|
||||||
ExternalID: source.Externalid.GetOr(""),
|
ExternalID: source.Externalid.GetOr(""),
|
||||||
|
|
||||||
// Status Information
|
// Status Information
|
||||||
|
|
@ -361,7 +361,7 @@ func toTemplateBreedingSource(source *models.FieldseekerPointlocation) *Breeding
|
||||||
Symbology: source.Symbology.GetOr(""),
|
Symbology: source.Symbology.GetOr(""),
|
||||||
|
|
||||||
// Geographical Data
|
// Geographical Data
|
||||||
LatLng: lat_lng,
|
LatLng: lat_lng,
|
||||||
Zone: source.Zone.GetOr(""),
|
Zone: source.Zone.GetOr(""),
|
||||||
Zone2: source.Zone2.GetOr(""),
|
Zone2: source.Zone2.GetOr(""),
|
||||||
Jurisdiction: source.Jurisdiction.GetOr(""),
|
Jurisdiction: source.Jurisdiction.GetOr(""),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue