From 92afa64fc5a291a48b9b2d8a37963e8dca843016 Mon Sep 17 00:00:00 2001 From: Petyo Stoyanov Date: Thu, 16 May 2024 10:53:03 +0300 Subject: [PATCH] [ID-90] Handle location processing on WebTools import (#95) * Update CHANGELOG.md * Do not process empty locations * Introduce geo adapter - in progress * Prepare more raw code * Geo adapter is in progress * Google communication - in progress * in progress * in progress * in progress * in progress * preprocess and process LocationLegacy * change the name of the env * resolve comments * fix the duration * Add appropriate comment as the images one. * We care only locations which are not empty string * Correct function name * Arh.. * Move to defined locations * Init all defined locations on startup * Get locations for processing * Get not processed lcoations * Process locations - in progress * Process locations - in progress * Search in google * Prepare search key * Fix lint issues * Revert timer --------- Co-authored-by: Petyo Stoyanov Co-authored-by: Stefan Vitanov --- CHANGELOG.md | 2 + core/application.go | 4 +- core/interfaces.go | 19 ++- core/logic_events.go | 245 +++++++++++++++++++++------- core/model/legacy_locations.go | 66 ++++++++ driven/geo/adapter.go | 129 +++++++++++++++ driven/storage/adapter.go | 22 +++ driven/storage/adapter_locations.go | 2 +- go.mod | 7 +- go.sum | 98 +++++------ main.go | 8 +- 11 files changed, 480 insertions(+), 122 deletions(-) create mode 100644 driven/geo/adapter.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c8bf74a..f6934867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Handle location processing on WebTools import [#90](https://github.com/rokwire/gateway-building-block/issues/90) [2.9.0] - 2024-05-07 ### Changed diff --git a/core/application.go b/core/application.go index 80bbf078..a873f30f 100644 --- a/core/application.go +++ b/core/application.go @@ -56,6 +56,7 @@ type Application struct { eventsBBAdapter EventsBBAdapter imageAdapter ImageAdapter + geoBBAdapter GeoAdapter //events logic eventsLogic eventsLogic @@ -94,6 +95,7 @@ func NewApplication(version string, build string, storage Storage, eventsBBAdapter EventsBBAdapter, imageAdapter ImageAdapter, + geoBBAdapter GeoAdapter, appntAdapters map[string]Appointments, logger *logs.Logger) *Application { application := Application{version: version, build: build, storage: storage, eventsBBAdapter: eventsBBAdapter, imageAdapter: imageAdapter, logger: logger, AppointmentAdapters: appntAdapters} @@ -106,7 +108,7 @@ func NewApplication(version string, build string, application.TPS = newAppTPS(&application) application.System = newAppSystem(&application) application.shared = newAppShared(&application) - application.eventsLogic = newAppEventsLogic(&application, eventsBBAdapter, *logger) + application.eventsLogic = newAppEventsLogic(&application, eventsBBAdapter, geoBBAdapter, *logger) return &application } diff --git a/core/interfaces.go b/core/interfaces.go index 69acc0a1..7b940172 100644 --- a/core/interfaces.go +++ b/core/interfaces.go @@ -99,6 +99,16 @@ type EventsBBAdapter interface { LoadAllLegacyEvents() ([]model.LegacyEvent, error) } +// GeoAdapter is used by core to get geo services +type GeoAdapter interface { + FindLocation(location string) (*model.LegacyLocation, error) +} + +// ImageAdapter is used to precess images +type ImageAdapter interface { + ProcessImage(item model.WebToolsEvent) (*model.ContentImagesURL, error) +} + // Storage is used by core to storage data - DB storage adapter, file storage adapter etc type Storage interface { RegisterStorageListener(listener storage.Listener) @@ -122,7 +132,6 @@ type Storage interface { FindCalendars(id string) (*[]model.UnitCalendar, error) InitializeLegacyLocations() error - //not used FindLegacyLocations() (model.LegacyLocationsListType, error) FindLegacyEventItems(context storage.TransactionContext) ([]model.LegacyEventItem, error) @@ -139,6 +148,9 @@ type Storage interface { FindImageItems() ([]model.ContentImagesURL, error) InsertImageItem(items model.ContentImagesURL) error + + FindLegacyLocationItems() ([]model.LegacyLocation, error) + InsertLegacyLocationItem(items model.LegacyLocation) error } // StorageListener represents storage listener @@ -190,8 +202,3 @@ type SuccessTeam interface { GetPrimaryCareProvider(uin string, accesstoken string, conf *model.EnvConfigData) (*[]model.SuccessTeamMember, int, error) GetAcademicAdvisors(uin string, calendars *[]model.UnitCalendar, accesstoken string, conf *model.EnvConfigData) (*[]model.SuccessTeamMember, int, error) } - -// ImageAdapter is used to precess images -type ImageAdapter interface { - ProcessImage(item model.WebToolsEvent) (*model.ContentImagesURL, error) -} diff --git a/core/logic_events.go b/core/logic_events.go index 193be9e6..ee540784 100644 --- a/core/logic_events.go +++ b/core/logic_events.go @@ -39,6 +39,7 @@ type eventsLogic struct { logger logs.Logger eventsBBAdapter EventsBBAdapter + geoBBAdapter GeoAdapter //web tools timer dailyWebToolsTimer *time.Timer @@ -198,7 +199,7 @@ func (e eventsLogic) setupWebToolsTimer() { leftToday := 86400 - nowSecondsInDay durationInSeconds = leftToday + desiredMoment // the time which left today + desired moment from tomorrow } - log.Println(durationInSeconds) + //log.Println(durationInSeconds) //duration := time.Second * time.Duration(3) duration := time.Second * time.Duration(durationInSeconds) e.logger.Infof("setupWebToolsTimer -> first call after %s", duration) @@ -263,6 +264,13 @@ func (e eventsLogic) processWebToolsEvents() { return } + //process the locations before the main processing + locationsData, err := e.processLocations(allWebToolsEvents) + if err != nil { + e.logger.Errorf("error on processing locations - %s", err) + return + } + now := time.Now() //in transaction @@ -304,7 +312,7 @@ func (e eventsLogic) processWebToolsEvents() { //prepare the id id := e.prepareID(wt.EventID, existingLegacyIdsMap) - le := e.constructLegacyEvent(wt, id, now, imagesData) + le := e.constructLegacyEvent(wt, id, now, imagesData, locationsData) newLegacyEvents = append(newLegacyEvents, le) } @@ -340,7 +348,7 @@ func (e eventsLogic) processImages(allWebtoolsEvents []model.WebToolsEvent) ([]m return nil, err } - e.logger.Infof("there are %d events to be processed as not proccesed", len(notProccesed)) + e.logger.Infof("there are %d events to be image processed as not proccesed", len(notProccesed)) //process the images which have not been processed err = e.applyProcessImages(notProccesed) @@ -533,7 +541,7 @@ func (e eventsLogic) loadAllWebToolsEvents() ([]model.WebToolsEvent, error) { return allWebToolsEvents, nil } -func (e eventsLogic) constructLegacyEvent(g model.WebToolsEvent, id string, now time.Time, imagesData []model.ContentImagesURL) model.LegacyEventItem { +func (e eventsLogic) constructLegacyEvent(g model.WebToolsEvent, id string, now time.Time, imagesData []model.ContentImagesURL, locationsData []model.LegacyLocation) model.LegacyEventItem { syncProcessSource := "webtools-direct" createdBy := g.CreatedBy @@ -562,7 +570,6 @@ func (e eventsLogic) constructLegacyEvent(g model.WebToolsEvent, id string, now outlookURL := fmt.Sprintf("https://calendars.illinois.edu/outlook2010/%s/%s.ics", g.CalendarID, g.EventID) recurrenceID, _ := recurenceIDtoInt(g.RecurrenceID) - location := constructLocation(g.Location) con := model.ContactLegacy{ContactName: g.CalendarName, ContactEmail: g.ContactEmail, ContactPhone: g.ContactName} var contacts []model.ContactLegacy contacts = append(contacts, con) @@ -658,13 +665,14 @@ func (e eventsLogic) constructLegacyEvent(g model.WebToolsEvent, id string, now //image url imageURL := e.getImageURL(g.EventID, imagesData) + loc := constructLocation(g, locationsData) return model.LegacyEventItem{SyncProcessSource: syncProcessSource, SyncDate: now, Item: model.LegacyEvent{ID: id, Category: g.EventType, CreatedBy: createdBy, OriginatingCalendarID: g.OriginatingCalendarID, IsVirtial: isVirtual, DataModified: modifiedDate, DateCreated: createdDate, Sponsor: g.Sponsor, Title: g.Title, CalendarID: g.CalendarID, SourceID: "0", AllDay: allDay, IsEventFree: costFree, Cost: g.Cost, LongDescription: g.Description, TitleURL: g.TitleURL, RegistrationURL: g.RegistrationURL, RecurringFlag: Recurrence, IcalURL: icalURL, OutlookURL: outlookURL, - RecurrenceID: recurrenceID, Location: &location, Contacts: contatsLegacy, + RecurrenceID: recurrenceID, Location: loc, Contacts: contatsLegacy, DataSourceEventID: g.EventID, StartDate: startDateStr, EndDate: endDateStr, Tags: tags, TargetAudience: targetAudience, ImageURL: imageURL}} } @@ -694,6 +702,106 @@ func (e eventsLogic) formatDate(wtDate string) string { return result } +func (e eventsLogic) processLocations(allWebtoolsEvents []model.WebToolsEvent) ([]model.LegacyLocation, error) { + //get the locations for processing + forProcessingLocations, err := e.getLocationsForProcessing(allWebtoolsEvents) + if err != nil { + return nil, err + } + + e.logger.Infof("there are %d locations for processing", len(forProcessingLocations)) + + //get the locations which are not processed + notProccesed, err := e.getNotProcessedLocations(forProcessingLocations) + if err != nil { + return nil, err + } + + e.logger.Infof("there are %d locations to be processed as not proccesed", len(notProccesed)) + + //process the locations which have not been processed + err = e.applyProcessLocations(notProccesed) + if err != nil { + e.logger.Error("Error on processing locations") + return nil, err + } + + //as we already have processed all locations just return this data to be used + locationsData, err := e.app.storage.FindLegacyLocationItems() + if err != nil { + return nil, err + } + + return locationsData, nil +} + +func (e eventsLogic) getLocationsForProcessing(allWebtoolsEvents []model.WebToolsEvent) ([]string, error) { + locationsMap := make(map[string]bool) + for _, event := range allWebtoolsEvents { + if len(event.Location) == 0 { + continue + } + + locationsMap[event.Location] = true + } + + res := []string{} + for location := range locationsMap { + res = append(res, location) + } + return res, nil +} + +func (e eventsLogic) getNotProcessedLocations(locationsForProcessing []string) ([]string, error) { + allProcessed, err := e.app.storage.FindLegacyLocations() + if err != nil { + return nil, err + } + + processedMap := make(map[string]bool) // map to keep track of processed events + for _, item := range allProcessed { + processedMap[item.Name] = true + } + + var notProcessedEvents []string + for _, loc := range locationsForProcessing { + if _, processed := processedMap[loc]; !processed { + notProcessedEvents = append(notProcessedEvents, loc) + } + } + + return notProcessedEvents, nil +} + +func (e eventsLogic) applyProcessLocations(locations []string) error { + i := 0 + for _, loc := range locations { + + //process the location + founded, err := e.geoBBAdapter.FindLocation(loc) + if err != nil { + return err + } + + if founded == nil { + e.logger.Infof("%d - %s NOT found", i, loc) + continue + } + + //mark as processed + err = e.app.storage.InsertLegacyLocationItem(*founded) + if err != nil { + return err + } + + e.logger.Infof("%d - %s WAS found", i, loc) + + i++ + } + return nil + +} + func recurenceIDtoInt(s string) (*int, error) { // Parse string to int parsedInt, err := strconv.Atoi(s) @@ -708,65 +816,80 @@ func recurenceIDtoInt(s string) (*int, error) { return result, nil } -func constructLocation(location string) model.LocationLegacy { +func constructLocation(event model.WebToolsEvent, locations []model.LegacyLocation) *model.LocationLegacy { + eventLocation := event.Location + + //check for empty location + if len(eventLocation) == 0 { + emptyLocation := constructEmptyLocation(eventLocation) + return &emptyLocation + } + + //in some cases we do not use the founded locations directly by the location key as in some cases the geo service(Google) + //gives bad results. In this case we have defined a new correct search key. + + //try if need to change the key + searchKey := usePredefinedLocationKey(event.CalendarName, event.Sponsor, event.Location) + if searchKey == nil { + searchKey = &event.Location + } + + //we have a search key, so try to find a location + founded := findLocation(*searchKey, locations) + if founded != nil { + //return it + + return &model.LocationLegacy{Description: founded.Description, + Latitude: *founded.Lat, Longitude: *founded.Long} + } + + //not found so return empty location + emptyLocation := constructEmptyLocation(eventLocation) + return &emptyLocation +} + +func constructEmptyLocation(location string) model.LocationLegacy { description := location latitude := 0.0 longitude := 0.0 + return model.LocationLegacy{Description: description, Latitude: float64(latitude), Longitude: float64(longitude)} +} + +// usePredefinedLocationKey looks for a static location based on the calendar name, sponsor, and location description +func usePredefinedLocationKey(calendarName, sponsor, location string) *string { - if location == "Davenport 109A" { - latitude = 40.107335 - longitude = -88.226069 - } else if location == "Nevada Dance Studio (905 W. Nevada St.)" { - latitude = 40.105825 - longitude = -88.219873 - } else if location == "18th Ave Library, 175 W 18th Ave, Room 205, Oklahoma City, OK" { - latitude = 36.102183 - longitude = -97.111245 - } else if location == "Champaign County Fairgrounds" { - latitude = 40.1202191 - longitude = -88.2178757 - } else if location == "Student Union SLC Conference room" { - latitude = 39.727282 - longitude = -89.617477 - } else if location == "Armory, room 172 (the Innovation Studio)" { - latitude = 40.104749 - longitude = -88.23195 - } else if location == "Student Union Room 235" { - latitude = 39.727282 - longitude = -89.617477 - } else if location == "Uni 206, 210, 211" { - latitude = 40.11314 - longitude = -88.225259 - } else if location == "Uni 205, 206, 210" { - latitude = 40.11314 - longitude = -88.225259 - } else if location == "Southern Historical Association Combs Chandler 30" { - latitude = 38.258116 - longitude = -85.756139 - } else if location == "St. Louis, MO" { - latitude = 38.694237 - longitude = -90.4493 - } else if location == "Student Union SLC" { - latitude = 39.727282 - longitude = -89.617477 - } else if location == "Purdue University, West Lafayette, Indiana" { - latitude = 40.425012 - longitude = -86.912645 - } else if location == "MP 7" { - latitude = 40.100803 - longitude = -88.23604 - } else if location == "116 Roger Adams Lab" { - latitude = 40.107741 - longitude = -88.224943 - } else if location == "2700 Campus Way 45221" { - latitude = 39.131894 - longitude = -84.519143 - } else if location == "The Orange Room, Main Library - 1408 W. Gregory Drive, Champaign IL" { - latitude = 40.1047044 - longitude = -88.22901039999999 + type tip struct { + CalendarName string + SponsorKeyword string + LocationKeyword string + AccessName string } - return model.LocationLegacy{Description: description, Latitude: float64(latitude), Longitude: float64(longitude)} + var tip4CalALoc = []tip{ + {CalendarName: "Krannert Center", SponsorKeyword: "", LocationKeyword: "studio", AccessName: "Krannert Center"}, + {CalendarName: "Krannert Center", SponsorKeyword: "", LocationKeyword: "stage", AccessName: "Krannert Center"}, + {CalendarName: "General Events", SponsorKeyword: "ncsa", LocationKeyword: "ncsa", AccessName: "NCSA"}, + {CalendarName: "National Center for Supercomputing Applications master calendar", SponsorKeyword: "", LocationKeyword: "ncsa", AccessName: "NCSA"}, + } + + for _, tip := range tip4CalALoc { + if tip.CalendarName == calendarName && + strings.Contains(strings.ToLower(sponsor), tip.SponsorKeyword) && + strings.Contains(strings.ToLower(location), tip.LocationKeyword) { + return &tip.AccessName + } + } + + return nil +} + +func findLocation(loc string, locations []model.LegacyLocation) *model.LegacyLocation { + for _, location := range locations { + if location.Name == loc { + return &location + } + } + return nil } // Contacts @@ -782,7 +905,7 @@ func contactsToDef(items []model.ContactLegacy) []model.ContactLegacy { } // newAppEventsLogic creates new appShared -func newAppEventsLogic(app *Application, eventsBBAdapter EventsBBAdapter, logger logs.Logger) eventsLogic { +func newAppEventsLogic(app *Application, eventsBBAdapter EventsBBAdapter, geoBBAdapter GeoAdapter, logger logs.Logger) eventsLogic { timerDone := make(chan bool) - return eventsLogic{app: app, eventsBBAdapter: eventsBBAdapter, timerDone: timerDone, logger: logger} + return eventsLogic{app: app, eventsBBAdapter: eventsBBAdapter, geoBBAdapter: geoBBAdapter, timerDone: timerDone, logger: logger} } diff --git a/core/model/legacy_locations.go b/core/model/legacy_locations.go index 1d3d1e35..0b8124d7 100644 --- a/core/model/legacy_locations.go +++ b/core/model/legacy_locations.go @@ -171,4 +171,70 @@ var DefaultLegacyLocations = LegacyLocationsListType{ Long: floatToPointer(-88.224943), Description: "116 Roger Adams Lab", }, + + //START CalName2Location + { + ID: uuid.NewString(), + Name: "General Events", + Lat: floatToPointer(0.0), + Long: floatToPointer(0.0), + Description: "General Events", + }, + { + ID: uuid.NewString(), + Name: "Krannert Center", + Lat: floatToPointer(40.1080244), + Long: floatToPointer(-88.224704), + Description: "Krannert Center", + }, + { + ID: uuid.NewString(), + Name: "Library Calendar", + Lat: floatToPointer(0.0), + Long: floatToPointer(0.0), + Description: "Library Calendar", + }, + { + ID: uuid.NewString(), + Name: "Facility Hours", + Lat: floatToPointer(0.0), + Long: floatToPointer(0.0), + Description: "Facility Hours", + }, + { + ID: uuid.NewString(), + Name: "Beckman Main Calendar", + Lat: floatToPointer(40.1157707), + Long: floatToPointer(-88.229393), + Description: "Beckman Main Calendar", + }, + { + ID: uuid.NewString(), + Name: "Lincoln Hall Theater Events", + Lat: floatToPointer(40.1066066), + Long: floatToPointer(-88.2304212), + Description: "Lincoln Hall Theater Events", + }, + { + ID: uuid.NewString(), + Name: "Foellinger Auditorium Events", + Lat: floatToPointer(40.1059431), + Long: floatToPointer(-88.2294751), + Description: "Foellinger Auditorium Events", + }, + { + ID: uuid.NewString(), + Name: "Department of Sociology", + Lat: floatToPointer(40.1066528), + Long: floatToPointer(-88.2305061), + Description: "Department of Sociology", + }, + { + ID: uuid.NewString(), + Name: "NCSA", + Lat: floatToPointer(40.1147743), + Long: floatToPointer(-88.2252053), + Description: "NCSA", + }, + //ENB CalName2Location } diff --git a/driven/geo/adapter.go b/driven/geo/adapter.go new file mode 100644 index 00000000..5ddc7de1 --- /dev/null +++ b/driven/geo/adapter.go @@ -0,0 +1,129 @@ +package geo + +import ( + "application/core/model" + "context" + "log" + + "github.com/google/uuid" + "github.com/rokwire/logging-library-go/v2/logs" + "googlemaps.github.io/maps" +) + +/* +var CalName2Location = map[string][2]float64{ + "General Events": {0.0, 0.0}, + "Krannert Center": {40.1080244, -88.224704}, + "Library Calendar": {0.0, 0.0}, + "Facility Hours": {0.0, 0.0}, + "Beckman Main Calendar": {40.1157707, -88.229393}, + "Lincoln Hall Theater Events": {40.1066066, -88.2304212}, + "Foellinger Auditorium Events": {40.1059431, -88.2294751}, + "Department of Sociology": {40.1066528, -88.2305061}, + "NCSA": {40.1147743, -88.2252053}, +}*/ + +/* +var DefinedLocation = map[string][2]float64{ + "Davenport 109A": {40.107335, -88.226069}, + "Nevada Dance Studio (905 W. Nevada St.)": {40.105825, -88.219873}, + "18th Ave Library, 175 W 18th Ave, Room 205, Oklahoma City, OK": {36.102183, -97.111245}, + "Champaign County Fairgrounds": {40.1202191, -88.2178757}, + "Student Union SLC Conference room": {39.727282, -89.617477}, + "Armory, room 172 (the Innovation Studio)": {40.104749, -88.23195}, + "Student Union Room 235": {39.727282, -89.617477}, + "Uni 206, 210, 211": {40.11314, -88.225259}, + "Uni 205, 206, 210": {40.11314, -88.225259}, + "Southern Historical Association Combs Chandler 30": {38.258116, -85.756139}, + "St. Louis, MO": {38.694237, -90.4493}, + "Student Union SLC": {39.727282, -89.617477}, + "Purdue University, West Lafayette, Indiana": {40.425012, -86.912645}, + "MP 7": {40.100803, -88.23604}, + "116 Roger Adams Lab": {40.107741, -88.224943}, + "2700 Campus Way 45221": {39.131894, -84.519143}, + "The Orange Room, Main Library - 1408 W. Gregory Drive, Champaign IL": {40.1047044, -88.22901039999999}, + + //CalName2Location + "General Events": {0.0, 0.0}, + "Krannert Center": {40.1080244, -88.224704}, + "Library Calendar": {0.0, 0.0}, + "Facility Hours": {0.0, 0.0}, + "Beckman Main Calendar": {40.1157707, -88.229393}, + "Lincoln Hall Theater Events": {40.1066066, -88.2304212}, + "Foellinger Auditorium Events": {40.1059431, -88.2294751}, + "Department of Sociology": {40.1066528, -88.2305061}, + "NCSA": {40.1147743, -88.2252053}, +} */ + +// Adapter implements the GeoAdapter interface +type Adapter struct { + googleMapsClient maps.Client + + log logs.Log +} + +// FindLocation finds the location the location +func (l Adapter) FindLocation(location string) (*model.LegacyLocation, error) { + return l.findLocationFromGoogle(location) +} + +func (l Adapter) findLocationFromGoogle(location string) (*model.LegacyLocation, error) { + req := &maps.GeocodingRequest{ + Address: location + ", Urbana", + Components: map[maps.Component]string{ + maps.ComponentAdministrativeArea: "Urbana", + maps.ComponentCountry: "US", + }, + } + + resp, err := l.googleMapsClient.Geocode(context.Background(), req) + if err != nil { + log.Printf("API Key Error: %v", err) + return nil, nil //not found on error + } + + if len(resp) != 0 { + lat := resp[0].Geometry.Location.Lat + lng := resp[0].Geometry.Location.Lng + legacyLocation := model.LegacyLocation{ID: uuid.NewString(), Name: location, + Description: location, Lat: &lat, Long: &lng} + + return &legacyLocation, nil + } + log.Printf("not found: %s", location) + + return nil, nil +} + +/* +func main() { + found, geoInfo := searchStaticLocation("Krannert Center", "", "studio 5") + if found { + println("GeoInfo found:", geoInfo.Description, geoInfo.Latitude, geoInfo.Longitude) + } else { + println("No GeoInfo found") + } + + client, err := maps.NewClient(maps.WithAPIKey("TODO")) + if err != nil { + log.Fatalf("Error creating client: %v", err) + } + + entry := make(map[string]interface{}) + fetchGeoData(client, "123 Main St, Urbana", entry) +} */ + +// NewGeoBBAdapter creates new instance +func NewGeoBBAdapter(googleAPIKey string, logger *logs.Logger) Adapter { + l := logger.NewLog("geo_bb_adapter", logs.RequestContext{}) + + client, err := maps.NewClient(maps.WithAPIKey(googleAPIKey)) + if err != nil { + log.Fatalf("Error creating google maps client: %v", err) + } + + return Adapter{ + googleMapsClient: *client, + log: *l, + } +} diff --git a/driven/storage/adapter.go b/driven/storage/adapter.go index 72575e3f..69c40625 100644 --- a/driven/storage/adapter.go +++ b/driven/storage/adapter.go @@ -547,6 +547,28 @@ func (a *Adapter) InsertImageItem(items model.ContentImagesURL) error { return nil } +// FindLegacyLocationItems finds all legacy locations stored in the database +func (a *Adapter) FindLegacyLocationItems() ([]model.LegacyLocation, error) { + filter := bson.M{} + var data []model.LegacyLocation + timeout := 15 * time.Second //15 seconds timeout + err := a.db.legacyLocations.FindWithParams(nil, filter, &data, nil, &timeout) + if err != nil { + return nil, errors.WrapErrorAction(logutils.ActionFind, model.TypeExample, filterArgs(nil), err) + } + + return data, nil +} + +// InsertLegacyLocationItem insertthe location of the event +func (a *Adapter) InsertLegacyLocationItem(items model.LegacyLocation) error { + _, err := a.db.legacyLocations.InsertOne(nil, items) + if err != nil { + return nil + } + return nil +} + // NewStorageAdapter creates a new storage adapter instance func NewStorageAdapter(mongoDBAuth string, mongoDBName string, mongoTimeout string, logger *logs.Logger) *Adapter { timeout, err := strconv.Atoi(mongoTimeout) diff --git a/driven/storage/adapter_locations.go b/driven/storage/adapter_locations.go index febf9968..22e83ff3 100644 --- a/driven/storage/adapter_locations.go +++ b/driven/storage/adapter_locations.go @@ -38,7 +38,7 @@ func (a *Adapter) InitializeLegacyLocations() error { func (a *Adapter) FindLegacyLocations() (model.LegacyLocationsListType, error) { var list model.LegacyLocationsListType - err := a.db.legacyEvents.FindWithContext(a.context, bson.D{}, &list, options.Find().SetSort(bson.D{{Key: "name", Value: 1}})) + err := a.db.legacyLocations.FindWithContext(a.context, bson.D{}, &list, options.Find().SetSort(bson.D{{Key: "name", Value: 1}})) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionFind, model.TypeEventLocations, nil, err) } diff --git a/go.mod b/go.mod index 1dd8cb14..20963563 100644 --- a/go.mod +++ b/go.mod @@ -7,17 +7,18 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 github.com/oapi-codegen/runtime v1.0.0 + github.com/rokwire/core-auth-library-go/v2 v2.2.0 github.com/rokwire/core-auth-library-go/v3 v3.2.0 github.com/rokwire/logging-library-go/v2 v2.3.0 github.com/swaggo/http-swagger v1.3.4 github.com/swaggo/swag v1.16.1 go.mongodb.org/mongo-driver v1.14.0 golang.org/x/sync v0.6.0 + googlemaps.github.io/maps v1.7.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/andybalholm/cascadia v1.3.2 // indirect github.com/casbin/casbin/v2 v2.82.0 // indirect @@ -55,7 +56,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/montanaflynn/stats v0.7.1 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect - github.com/rokwire/core-auth-library-go v1.0.9 // indirect - github.com/rokwire/core-auth-library-go/v2 v2.2.0 // indirect + go.opencensus.io v0.22.3 // indirect + golang.org/x/time v0.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7f6318d5..a7e87acd 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= @@ -10,20 +10,15 @@ github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsVi github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= -github.com/aws/aws-sdk-go v1.39.4/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= -github.com/aws/aws-sdk-go v1.44.296 h1:ALRZIIKI+6EBWDiWP4RHWmOtHZ7dywRzenL4NWgNI2A= -github.com/aws/aws-sdk-go v1.44.296/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.50.29 h1:Ol2FYzesF2tsQrgVSnDWRFI60+FsSqKKdt7MLlZKubc= github.com/aws/aws-sdk-go v1.50.29/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= -github.com/casbin/casbin/v2 v2.31.10/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= -github.com/casbin/casbin/v2 v2.71.1 h1:LRHyqM0S1LzM/K59PmfUIN0ZJfLgcOjL4OhOQI/FNXU= -github.com/casbin/casbin/v2 v2.71.1/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/casbin/casbin/v2 v2.82.0 h1:2CgvunqQQoepcbGRnMc9vEcDhuqh3B5yWKoj+kKSxf8= github.com/casbin/casbin/v2 v2.82.0/go.mod h1:jX8uoN4veP85O/n2674r2qtfSXI6myvxW85f6TH50fw= github.com/casbin/govaluate v1.1.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/casbin/govaluate v1.1.1 h1:J1rFKIBhiC5xr0APd5HP6rDL+xt+BRoyq1pa4o2i/5c= github.com/casbin/govaluate v1.1.1/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -42,24 +37,26 @@ github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= @@ -74,6 +71,7 @@ github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPci github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -81,9 +79,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -96,41 +91,33 @@ github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oapi-codegen/runtime v1.0.0 h1:P4rqFX5fMFWqRzY9M/3YF9+aPSPPB06IzP2P7oOxrWo= github.com/oapi-codegen/runtime v1.0.0/go.mod h1:LmCUMQuPB4M/nLXilQXhHw+BLZdDb18B34OO356yJ/A= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rokwire/core-auth-library-go v1.0.9 h1:S1BQ/j3V+wGF/2P1K3HKBjX95/Zm5Kt9AP8Nq0NfeEU= -github.com/rokwire/core-auth-library-go v1.0.9/go.mod h1:y5XiXjTD52DDX0iHAR8J0kWls/xCgUtqyBFWjp/cmQo= github.com/rokwire/core-auth-library-go/v2 v2.2.0 h1:AMnYyGBIQMVY2w/+gYeVl05BqpBcjttRKj3urXO2OVo= github.com/rokwire/core-auth-library-go/v2 v2.2.0/go.mod h1:0MO0lt55BvVjLmegbbDeTyNQR+UL0wKzOvZvnMtRw0w= -github.com/rokwire/core-auth-library-go/v3 v3.0.1 h1:7kZqnXq3lsb8sU+YxXEtHXjmxvFd5X/VpqQKiy/RnqA= -github.com/rokwire/core-auth-library-go/v3 v3.0.1/go.mod h1:VtpVajbA8JPjOzvEFQpxOm4pfok4z/8a2WshErTZd7s= github.com/rokwire/core-auth-library-go/v3 v3.2.0 h1:+cCPU9sc5oVYvEVf1Nh54Te9t08/xNX6GQaxdSHOKMA= github.com/rokwire/core-auth-library-go/v3 v3.2.0/go.mod h1:ItkkDZPFcV7F5JBMaOuN/zgNKEkJ/zfhT6FAYLBd6h4= -github.com/rokwire/logging-library-go v1.0.0/go.mod h1:yntksZF2TDmxid9MwDnAAt95TeLMYo6chL0VUyIaFHk= -github.com/rokwire/logging-library-go/v2 v2.2.0 h1:SKFq+rrl+li1RhEhB7CV+pVcptu/nurX9/DWj/oRaw4= -github.com/rokwire/logging-library-go/v2 v2.2.0/go.mod h1:6QSqTlk5nNQcZweqg0sLCCoIwpRpTu3AmOi7EJy38Tg= github.com/rokwire/logging-library-go/v2 v2.3.0 h1:79paNwa+DwvaMNyTqg4emkXbn6xHIkpmDKWfQ2K6FUc= github.com/rokwire/logging-library-go/v2 v2.3.0/go.mod h1:ns94awYfgAzKynb/sI4X8TP6UGovfiGHLqVE2wzccR8= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= @@ -150,63 +137,60 @@ github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= +go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -215,12 +199,17 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= @@ -231,8 +220,17 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +googlemaps.github.io/maps v1.7.0 h1:9yAEgaAyg6bWn+TpY8PmNJ0C+YfUBtN9KjJypjCOioo= +googlemaps.github.io/maps v1.7.0/go.mod h1:cCq0JKYAnnCRSdiaBi7Ex9CW15uxIAk7oPi8V/xEh6s= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -241,6 +239,7 @@ gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8 gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -248,3 +247,4 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go index 2f65f176..8af576e4 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ package main import ( "application/core" "application/driven/eventsbb" + "application/driven/geo" "application/driven/image" "application/driven/storage" "application/driven/uiucadapters" @@ -130,8 +131,13 @@ func main() { logger.Fatalf("Error initializing sports adapter: %v", err) } + // geo bb adapter + geoBBGoogleAPIKey := envLoader.GetAndLogEnvVar(envPrefix+"GOOGLE_KEY", true, true) + geoBBAdapter := geo.NewGeoBBAdapter(geoBBGoogleAPIKey, logger) + // application - application := core.NewApplication(Version, Build, storageAdapter, eventsBBAdapter, imageAdapter, appointments, logger) + application := core.NewApplication(Version, Build, storageAdapter, eventsBBAdapter, + imageAdapter, geoBBAdapter, appointments, logger) err = application.Start() if err != nil { logger.Fatalf("Cannot start the Application module: %v", err)