Skip to content

[ID-39] WebTools events handling #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 121 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
feab08b
in progress
Jan 9, 2024
638ab9c
in progress
Jan 10, 2024
56cf14f
in progress
Jan 10, 2024
86251f9
in progress
Jan 11, 2024
e4e208c
in progress
Jan 14, 2024
2b7940c
fix
Jan 15, 2024
b478272
Better files names
petyos Jan 16, 2024
5384ad1
Update legacy event entity
petyos Jan 16, 2024
0ee5689
Fix build
petyos Jan 16, 2024
8e56d4a
Disable load events for now.
petyos Jan 16, 2024
01579dd
ResponseWS is renamed to WebToolsEvent
petyos Jan 16, 2024
f50c02e
Add events bb adapter
petyos Jan 16, 2024
7ebae31
Use the model struct
petyos Jan 16, 2024
ecf2cc6
Use env variable
petyos Jan 16, 2024
6742db4
Hook up events bb adapter
petyos Jan 16, 2024
58bcd95
Load legacy events from events BB
petyos Jan 17, 2024
94d13f1
Move the logger in the adapter
petyos Jan 17, 2024
7ba2d11
Define legacy event item
petyos Jan 17, 2024
8db2541
Add index
petyos Jan 17, 2024
039eede
Do not start if the initial import fails
petyos Jan 17, 2024
8cdd7ed
Prepare the events which will be stored
petyos Jan 17, 2024
56f01bc
Import initial events - in progress
petyos Jan 17, 2024
7f1a62e
Import initial events - in progress
petyos Jan 17, 2024
9fe917e
Fix dependencies issues
petyos Jan 17, 2024
57dbc83
Add bson tag
petyos Jan 17, 2024
e65fbdc
Add global configs collection
petyos Jan 17, 2024
316ce3a
Merge branch 'develop' into issues/39 - resolved conflicts
petyos Jan 18, 2024
91c8d96
Prepare webtools convertion
petyos Jan 19, 2024
8313bab
Prepare construct legacy events
petyos Jan 19, 2024
13d28a2
Prepare for processing
petyos Jan 19, 2024
94c992f
Fix build
petyos Jan 19, 2024
a6e9f20
Implement global configs storage functions
petyos Jan 19, 2024
69f66f0
Import happens in transaction
petyos Jan 19, 2024
de5f2bf
Initial import happens only once
petyos Jan 19, 2024
01606d2
Add timer
petyos Jan 19, 2024
b125866
Fix lint issue
petyos Jan 19, 2024
cb0d7bd
in progress
Jan 22, 2024
62365c7
in progress
Jan 24, 2024
4fdbb2e
Cover legacy locations
mdryankov Jan 24, 2024
abf2307
Merge branch 'issues/39' of github.com:rokwire/gateway-building-block…
mdryankov Jan 24, 2024
4ddbfa1
hardcode the locations
Jan 25, 2024
4225e76
in progress
Jan 26, 2024
685d205
in progress
Jan 26, 2024
05c642b
set in transaction
Jan 26, 2024
4df3c3c
Do not execute the timer on startup
petyos Jan 27, 2024
db9977e
Grouped by entities
petyos Jan 27, 2024
ecf0fe0
More organised code
petyos Jan 27, 2024
afd99fa
Enable function by function when we need it - step by step
petyos Jan 27, 2024
5d80df5
Split the code in functions
petyos Jan 27, 2024
1270b6d
Split the code..
petyos Jan 27, 2024
418c772
Better log
petyos Jan 28, 2024
ec895e8
Better naming
petyos Jan 28, 2024
5c987f4
Revert the name to WebToolsResponse
petyos Jan 28, 2024
f20361a
Simplify loading the events
petyos Jan 28, 2024
9c14684
Remove commented code
petyos Jan 28, 2024
2ca1069
Do not commit dev commented code
petyos Jan 29, 2024
2e284c7
Clean up
petyos Jan 29, 2024
3aba240
Add algorithm
petyos Jan 29, 2024
02198b6
Add algorithm - part 2
petyos Jan 29, 2024
b7ddf26
in progress
Jan 29, 2024
63cfebf
in progress
Jan 29, 2024
2e40024
fix
Jan 29, 2024
ee51219
Add comment 1
petyos Jan 29, 2024
4900489
Add comment 2
petyos Jan 29, 2024
bcbd399
Add comment 3
petyos Jan 29, 2024
7221bcd
in progress
Jan 30, 2024
633c43a
Merge branch 'issues/39' of https://github.com/rokwire/gateway-buildi…
Jan 30, 2024
b21c6a5
in progress
Jan 30, 2024
ac0f0ca
remove comments
Jan 30, 2024
66c91bc
delete from the database
Jan 30, 2024
265244e
in progress
Jan 30, 2024
88ff24b
in progress
Jan 30, 2024
644c31f
store the legacy events
Jan 31, 2024
854b2f8
fix lint issue
Jan 31, 2024
93d1b0a
Do not commit dev comments
petyos Feb 1, 2024
1370b97
Skip if there is no identifier
petyos Feb 1, 2024
d9958bc
Count unique item
petyos Feb 1, 2024
16c2cfb
there are a lot of duplicate items, so we need to fix them
petyos Feb 1, 2024
c0d93e8
We always should have an identifier
petyos Feb 1, 2024
15d3f02
Use the transaction correctly
petyos Feb 1, 2024
bbeae4f
Add correct syncProcessSource
petyos Feb 1, 2024
e51ec28
Convert from webtools to legacy events
petyos Feb 1, 2024
f273619
Reuse code
petyos Feb 1, 2024
8905141
Fix lint issue
petyos Feb 1, 2024
196e136
set the docs
Feb 1, 2024
8ff2f87
structure the API
Feb 1, 2024
039a9ee
Revert dev comments
petyos Feb 2, 2024
703902c
Fix duplicate data
petyos Feb 2, 2024
23c0010
get the legacyEvents from storage
Feb 2, 2024
9e4cffa
Merge branch 'issues/39' into getLegacyEventApi
Feb 2, 2024
22e47ce
Fix created by
petyos Feb 2, 2024
9cfeda4
Fix date created and date modified
petyos Feb 2, 2024
c83f808
Remove unused code
petyos Feb 2, 2024
0ee8f27
Fix location
petyos Feb 2, 2024
345531c
Dates in progress
petyos Feb 2, 2024
44f8b74
Dates in rpogress
petyos Feb 2, 2024
ea301e6
Fix dates
petyos Feb 2, 2024
c7bb19a
Fix dates
petyos Feb 2, 2024
ab98cf5
Revert dev code
petyos Feb 2, 2024
ca00086
get all Legacy Event and made apikey authentication
Feb 2, 2024
5482a59
Merge branch 'issues/39' into getLegacyEventApi
Feb 2, 2024
df5d1f4
secrets
Feb 2, 2024
d5eee4a
Use prefix
petyos Feb 5, 2024
84bdd7b
Fix lint issue
petyos Feb 5, 2024
30eb717
Fix lint issue
petyos Feb 5, 2024
c95318c
Do not pass null context
petyos Feb 5, 2024
f27b895
Fix various lint issues
petyos Feb 5, 2024
c42ff77
Fix various lint issues
petyos Feb 5, 2024
1ec4c82
Do not put parasites
petyos Feb 5, 2024
c09fb3b
Fix build
petyos Feb 5, 2024
b8f612b
What if error occured
petyos Feb 5, 2024
4d0fcbd
this processing should happen in the core module, not here
petyos Feb 5, 2024
8acc837
You have an item field, do not recreate
petyos Feb 5, 2024
7213676
Give appropriate names of the variables
petyos Feb 5, 2024
d7d6d05
Leave empty line as others
petyos Feb 5, 2024
28f98ee
Add label
petyos Feb 5, 2024
dad3c3e
Use the correct header
petyos Feb 5, 2024
72ae63f
API is not deprecated
petyos Feb 5, 2024
ad774ca
Get legacy event api (#44)
petyos Feb 5, 2024
18f626b
secrets
Feb 7, 2024
da2c084
Merge branch 'develop' into issues/39
Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": 223
}
],
"driver/web/auth.go": [
{
"type": "Secret Keyword",
"filename": "driver/web/auth.go",
"hashed_secret": "8435dc709de99714b7bcb7e6a9c9d4c498d7d38a",
"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-02T12:25:52Z"
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
### Added
- WebTools events handling [#39](https://github.com/rokwire/gateway-building-block/issues/39)
- added successteam end point
- added successteam/pcp end point
- added successteam/adivsors 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