-
Notifications
You must be signed in to change notification settings - Fork 748
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
Distributed error reporting: Setting up the database that stores all the errors #12250
Merged
akolson
merged 6 commits into
learningequality:distributed-error-reporting
from
thesujai:distributed-error-reporting
Jun 11, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d814aa1
add errors in additional_sqlite_databases
thesujai afe3ad9
add errorreports database in aditional sqlite db
thesujai 5e10f53
create new errorreports app
thesujai abb63f3
add ErrorReports db router
thesujai 0e01b17
change ellipsis to pass
thesujai 20e540c
remove unused ready
thesujai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class KolibriErrorConfig(AppConfig): | ||
name = "kolibri.core.errorreports" | ||
label = "errorreports" | ||
verbose_name = "Kolibri ErrorReports" | ||
|
||
def ready(self): | ||
... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from kolibri.deployment.default.sqlite_db_names import ERROR_REPORTS | ||
|
||
|
||
class ErrorReportsRouter(object): | ||
""" | ||
Determine how to route database calls for the ErrorReports app. | ||
ref: https://docs.djangoproject.com/en/5.0/topics/db/multi-db/ | ||
|
||
""" | ||
|
||
def db_for_read(self, model, **hints): | ||
if model._meta.app_label == "errorreports": | ||
return ERROR_REPORTS | ||
return None | ||
|
||
def db_for_write(self, model, **hints): | ||
if model._meta.app_label == "errorreports": | ||
return ERROR_REPORTS | ||
return None | ||
|
||
def allow_relation(self, obj1, obj2, **hints): | ||
if ( | ||
obj1._meta.app_label == "errorreports" | ||
and obj2._meta.app_label == "errorreports" | ||
): | ||
return True | ||
elif "errorreports" not in [obj1._meta.app_label, obj2._meta.app_label]: | ||
return None | ||
|
||
return False | ||
|
||
def allow_migrate(self, db, app_label, model_name=None, **hints): | ||
if app_label == "errorreports": | ||
return db == ERROR_REPORTS | ||
elif db == ERROR_REPORTS: | ||
return False | ||
|
||
return None |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably no use case for this method. However if there is, then its worth changing its body from
...
topass
that is more explicitThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought both were the same thing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to pass!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass is more explicit. ... could mean a host of things.
It goes back to my earlier question. Do we really need the ready method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not now, some apps inside core had it defined this way with pass. So I just copy-pasted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thinks it's best we remove it as it won't really be necessary.