Skip to content

Commit

Permalink
[ID-39] WebTools events handling (#41)
Browse files Browse the repository at this point in the history
* in progress

* in progress

* in progress

* in progress

* in progress

* fix

* Better files names

* Update legacy event entity

* Fix build

* Disable load events for now.

* ResponseWS is renamed to WebToolsEvent

* Add events bb adapter

* Use the model struct

* Use env variable

* Hook up events bb adapter

* Load legacy events from events BB

* Move the logger in the adapter

* Define legacy event item

* Add index

* Do not start if the initial import fails

* Prepare the events which will be stored

* Import initial events - in progress

* Import initial events - in progress

* Fix dependencies issues

* Add bson tag

* Add global configs collection

* Prepare webtools convertion

* Prepare construct legacy events

* Prepare for processing

* Fix build

* Implement global configs storage functions

* Import happens in transaction

* Initial import happens only once

* Add timer

* Fix lint issue

* in progress

* in progress

* Cover legacy locations

* hardcode the locations

* in progress

* in progress

* set in transaction

* Do not execute the timer on startup

* Grouped by entities

* More organised code

* Enable function by function when we need it - step by step

* Split the code in functions

* Split the code..

* Better log

* Better naming

* Revert the name to WebToolsResponse

* Simplify loading the events

* Remove commented code

* Do not commit dev commented code

* Clean up

* Add algorithm

* Add algorithm - part 2

* in progress

* in  progress

* fix

* Add comment 1

* Add comment 2

* Add comment 3

* in progress

* in progress

* remove comments

* delete from the database

* in progress

* in progress

* store the legacy events

* fix lint issue

* Do not commit dev comments

* Skip if there is no identifier

* Count unique item

* there are a lot of duplicate items, so we need to fix them

* We always should have an identifier

* Use the transaction correctly

* Add correct syncProcessSource

* Convert from webtools to legacy events

* Reuse code

* Fix lint issue

* set the docs

* structure the API

* Revert dev comments

* Fix duplicate data

* get the legacyEvents from storage

* Fix created by

* Fix date created and date modified

* Remove unused code

* Fix location

* Dates in progress

* Dates in rpogress

* Fix dates

* Fix dates

* Revert dev code

* get all Legacy Event and made apikey authentication

* secrets

* Use prefix

* Fix lint issue

* Fix lint issue

* Do not pass null context

* Fix various lint issues

* Fix various lint issues

* Do not put parasites

* Fix build

* What if error occured

* this processing should happen in the core module, not here

* You have an item field, do not recreate

* Give appropriate names of the variables

* Leave empty line as others

* Add label

* Use the correct header

* API is not deprecated

* secrets

---------

Co-authored-by: Stefan Vitanov <[email protected]>
Co-authored-by: Petyo Stoyanov <[email protected]>
Co-authored-by: Mladen Dryankov <[email protected]>
  • Loading branch information
4 people authored Feb 8, 2024
1 parent e620eef commit bd0da3a
Show file tree
Hide file tree
Showing 39 changed files with 2,003 additions and 265 deletions.
44 changes: 37 additions & 7 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -105,12 +109,6 @@
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
},
{
"path": "detect_secrets.filters.regex.should_exclude_file",
"pattern": [
"go.sum"
]
}
],
"results": {
Expand Down Expand Up @@ -140,7 +138,39 @@
"is_verified": false,
"line_number": 41
}
],
"driver/web/adapter.go": [
{
"type": "Secret Keyword",
"filename": "driver/web/adapter.go",
"hashed_secret": "a7d09aaaf55864f7ce39a7715aabed433c3fe661",
"is_verified": false,
"line_number": 226
}
],
"driver/web/auth.go": [
{
"type": "Secret Keyword",
"filename": "driver/web/auth.go",
"hashed_secret": "71855a10ce38ee3598463e19b9737c525f3f330a",
"is_verified": false,
"line_number": 77
},
{
"type": "Secret Keyword",
"filename": "driver/web/auth.go",
"hashed_secret": "36c48d6ac9d10902792fa78b9c2d7d535971c2cc",
"is_verified": false,
"line_number": 199
},
{
"type": "Secret Keyword",
"filename": "driver/web/auth.go",
"hashed_secret": "fbc6c7d85067efe1a3dcf092a0999044c14b5fa5",
"is_verified": false,
"line_number": 212
}
]
},
"generated_at": "2023-07-06T15:24:39Z"
"generated_at": "2024-02-07T07:09:43Z"
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ 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]
### Added
- WebTools events handling [#39](https://github.com/rokwire/gateway-building-block/issues/39)

[2.1.0] - 2024-02-07
- added successteam end point
- added successteam/pcp end point
Expand Down
6 changes: 3 additions & 3 deletions core/app_admin.go → core/apis_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package core

import (
"application/core/interfaces"
"application/core/model"
"time"

Expand Down Expand Up @@ -53,7 +52,7 @@ func (a appAdmin) UpdateExample(example model.Example) error {

// AppendExample appends to the data in an example - Example of transaction usage
func (a appAdmin) AppendExample(example model.Example) (*model.Example, error) {
now := time.Now()
/*now := time.Now()
var newExample *model.Example
transaction := func(storage interfaces.Storage) error {
oldExample, err := storage.FindExample(example.OrgID, example.AppID, example.ID)
Expand All @@ -78,7 +77,8 @@ func (a appAdmin) AppendExample(example model.Example) (*model.Example, error) {
return nil, errors.WrapErrorAction(logutils.ActionCommit, logutils.TypeTransaction, nil, err)
}
return newExample, nil
return newExample, nil */
return nil, nil
}

// DeleteExample deletes an Example by ID
Expand Down
10 changes: 10 additions & 0 deletions core/app_bbs.go → core/apis_bbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ func (a appBBs) DeleteAppointment(uin string, providerid int, sourceid string, a
}
return ret, nil
}
func (a appBBs) GetLegacyEvents() ([]model.LegacyEvent, error) {

leEvents, err := a.app.storage.FindAllLegacyEvents()
if err != nil {
return nil, err
}

return leEvents, nil

}

// newAppBBs creates new appBBs
func newAppBBs(app *Application) appBBs {
Expand Down
30 changes: 21 additions & 9 deletions core/app_client.go → core/apis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
package core

import (
"application/core/interfaces"
"application/core/model"
"application/driven/uiucadapters"

"encoding/json"
"os"
)

// appClient contains client implementations
type appClient struct {
app *Application
Courseadapter interfaces.Courses
LocationAdapter interfaces.WayFinding
LaundryAdapter interfaces.LaundryService
ContactAdapter interfaces.Contact
SuccessTeamAdapter interfaces.SuccessTeam
Courseadapter Courses
LocationAdapter WayFinding
LaundryAdapter LaundryService
ContactAdapter Contact
SuccessTeamAdapter SuccessTeam
}

// GetExample gets an Example by ID
Expand Down Expand Up @@ -147,7 +147,13 @@ func (a appClient) GetTermSessions() (*[4]model.TermSession, error) {

func (a appClient) GetSuccessTeam(uin string, unitid string, accesstoken string) (*model.SuccessTeam, int, error) {
conf, _ := a.app.GetEnvConfigs()
retData, status, err := a.SuccessTeamAdapter.GetSuccessTeam(uin, unitid, accesstoken, conf)

calendars, err := a.app.storage.FindCalendars(unitid)
if err != nil {
return nil, 500, err
}

retData, status, err := a.SuccessTeamAdapter.GetSuccessTeam(uin, calendars, accesstoken, conf)
if err != nil {
return nil, status, err
}
Expand All @@ -166,7 +172,13 @@ func (a appClient) GetPrimaryCareProvider(uin string, accesstoken string) (*[]mo

func (a appClient) GetAcademicAdvisors(uin string, unitid string, accesstoken string) (*[]model.SuccessTeamMember, int, error) {
conf, _ := a.app.GetEnvConfigs()
retData, status, err := a.SuccessTeamAdapter.GetAcademicAdvisors(uin, unitid, accesstoken, conf)

calendars, err := a.app.storage.FindCalendars(unitid)
if err != nil {
return nil, 500, err
}

retData, status, err := a.SuccessTeamAdapter.GetAcademicAdvisors(uin, calendars, accesstoken, conf)
if err != nil {
return nil, status, err
}
Expand All @@ -193,6 +205,6 @@ func newAppClient(app *Application) appClient {
client.LaundryAdapter = uiucadapters.NewCSCLaundryAdapter(laundryAssets)
client.Courseadapter = uiucadapters.NewCourseAdapter()
client.LocationAdapter = uiucadapters.NewUIUCWayFinding()
client.SuccessTeamAdapter = uiucadapters.NewSuccessTeamAdapter(app.storage)
client.SuccessTeamAdapter = uiucadapters.NewSuccessTeamAdapter()
return client
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 29 additions & 12 deletions core/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package core

import (
"application/core/interfaces"
"application/core/model"

"github.com/rokwire/core-auth-library-go/v3/authutils"
Expand All @@ -41,26 +40,39 @@ type Application struct {
version string
build string

Default interfaces.Default // expose to the drivers adapters
Client interfaces.Client // expose to the drivers adapters
Admin interfaces.Admin // expose to the drivers adapters
BBs interfaces.BBs // expose to the drivers adapters
TPS interfaces.TPS // expose to the drivers adapters
System interfaces.System // expose to the drivers adapters
Default Default // expose to the drivers adapters
Client Client // expose to the drivers adapters
Admin Admin // expose to the drivers adapters
BBs BBs // expose to the drivers adapters
TPS TPS // expose to the drivers adapters
System System // expose to the drivers adapters
shared Shared

AppointmentAdapters map[string]interfaces.Appointments //expose to the different vendor specific appointment adapters
AppointmentAdapters map[string]Appointments //expose to the different vendor specific appointment adapters

logger *logs.Logger

storage interfaces.Storage
storage Storage

eventsBBAdapter EventsBBAdapter

//events logic
eventsLogic eventsLogic
}

// Start starts the core part of the application
func (a *Application) Start() {
func (a *Application) Start() error {
//set storage listener
storageListener := storageListener{app: a}
a.storage.RegisterStorageListener(&storageListener)

err := a.eventsLogic.start()
if err != nil {
return err
}

//no error
return nil
}

// GetEnvConfigs retrieves the cached database env configs
Expand All @@ -77,8 +89,12 @@ func (a *Application) GetEnvConfigs() (*model.EnvConfigData, error) {
}

// NewApplication creates new Application
func NewApplication(version string, build string, storage interfaces.Storage, appntAdapters map[string]interfaces.Appointments, logger *logs.Logger) *Application {
application := Application{version: version, build: build, storage: storage, logger: logger, AppointmentAdapters: appntAdapters}
func NewApplication(version string, build string,
storage Storage,
eventsBBAdapter EventsBBAdapter,
appntAdapters map[string]Appointments,
logger *logs.Logger) *Application {
application := Application{version: version, build: build, storage: storage, eventsBBAdapter: eventsBBAdapter, logger: logger, AppointmentAdapters: appntAdapters}

//add the drivers ports/interfaces
application.Default = newAppDefault(&application)
Expand All @@ -88,6 +104,7 @@ func NewApplication(version string, build string, storage interfaces.Storage, ap
application.TPS = newAppTPS(&application)
application.System = newAppSystem(&application)
application.shared = newAppShared(&application)
application.eventsLogic = newAppEventsLogic(&application, eventsBBAdapter, *logger)

return &application
}
Loading

0 comments on commit bd0da3a

Please sign in to comment.