-
Notifications
You must be signed in to change notification settings - Fork 0
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
Architecture refactorization. #50
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b811dd5
to
e21f72d
Compare
bf5aaee
to
4e5f4f1
Compare
…only by withings for now).
All withings db opeations have been moved to the repository now (which is called by usecases).
Make withings modules which need oauth settings only depend on a subset of settings, WithingsOAuthSettings, instead of the whole Settings. For the withings oauth update token callback, remove code regarding the db from the oauth config, and put it in the usecase_update_user_oauth instead. Move the withings.oauth module to oauth.withingsconfig. Now the services.withings package only has the api module. Will think of a better place to put it...
4e5f4f1
to
339c736
Compare
2654aa9
to
cf3950e
Compare
Rough sketch of architecture in progress: macro viewflowchart TB
subgraph main
end
subgraph routes
end
subgraph tasks
end
subgraph domain
end
%%subgraph core
%%end
subgraph data
end
subgraph remoteservices
end
subgraph oauth
end
domain --> remoteservices
domain --> data
%%domain --> core
%%remoteservices --> core
remoteservices --> oauth
%%oauth --> core
routes --> domain
tasks --> domain
main --> routes
main --> tasks
detailed viewflowchart TB
subgraph main
end
subgraph routes
subgraph withingsroutes
end
subgraph fitbitroutes
end
end
subgraph tasks
subgraph fitbittasks
end
end
subgraph logger
end
subgraph settings
end
subgraph domain
domainmodels[models]
usecases
modelmappers
end
subgraph core
coremodels[models]
exceptions
end
subgraph data
subgraph repositories
withingsrepository
fitbitrepository
repomodels[models]
end
subgraph database
connection
dbmodels[models]
end
end
subgraph remoteservices
fitbitapi
withingsapi
end
subgraph oauth
withingsoauth
fitbitoauth
oauth2[oauth]
end
repositories --> database
usecases --> domainmodels
usecases --> repositories
usecases --> remoteservices
usecases --> core
modelmappers --> coremodels
modelmappers --> domainmodels
modelmappers --> repomodels
fitbitoauth --> oauth2
withingsoauth --> oauth2
remoteservices --> core
remoteservices --> oauth
withingsroutes --> usecases
fitbitroutes --> usecases
fitbittasks --> usecases
main --> routes
main --> tasks
main --> settings
main --> logger
|
Accept a `FitnessData` with no weight value. Reload the user db objects after adding them. Fix a bug creating a new fitbit user for an existing user having a withings account (same slack alias). And vice versa.
When reading oauth_expiration_date from the database, add the utc tzinfo before using it. Use `datetime.now(timezone.utc)` instead of `datetime.utcnow()`, to get the current time in utc.
…he db, not the whole user.
…cess_new_weight. usecase_get_last_weight is just supposed to fetch the new weight from the network. usecase_process_new_weight calls usecase_get_last_weight and has the other business logic around it (saving the new weight to db, creating the WeightData to give to the slack use case to post to slack).
Add tests for duplicate fitbit and withings notifications. Add test scenarios for login with existing users. Move oauth tests to routes folder.
Isolate the message creation into a separate function. A future commit adds tests for this function.
Rework the scheduler, to avoid warnings about an unawaited coroutine, from tests. Use asyncio.create_task() to create a task which runs the polling every X seconds.
03eeebb
to
8fa2727
Compare
This was referenced Feb 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Architecture redesign
Redesign the architecture into layers.
Add mermaid diagrams.
Tests
Add tests to cover most of the app (97% coverage currently).
Other changes