-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from dmm-com/v3.0-dev
Merge all changing of updating Django
- Loading branch information
Showing
39 changed files
with
573 additions
and
266 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
max-line-length = 100 | ||
exclude = | ||
./venv, | ||
./.venv, | ||
./.tox, | ||
./*/migrations, | ||
.manage.py |
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
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
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,14 @@ | ||
import random | ||
from django.conf import settings | ||
|
||
|
||
def get_slave_db(): | ||
'''Change the DB query request to Slave. | ||
The slave DB has a replication delay compared to the master DB. | ||
There is a problem if change all read query requests to slaves. | ||
Use this function only for query requests that can afford replication delays. | ||
Usage: | ||
Entry.objects.using(get_slave_db()).filter(...) | ||
''' | ||
return random.choice(settings.AIRONE['DB_SLAVES']) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
|
||
from airone.lib.db import get_slave_db | ||
from django.conf import settings | ||
|
||
|
||
class AirOneDBTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# this saves original configurations to be able to retrieve them | ||
self.orig_conf_db_slaves = settings.AIRONE['DB_SLAVES'] | ||
|
||
# this enables do profiling | ||
settings.AIRONE['DB_SLAVES'] = ['slave1', 'slave2'] | ||
|
||
def tearDown(self): | ||
# this retrieves original configurations | ||
settings.AIRONE['ENABLE_PROFILE'] = self.orig_conf_db_slaves | ||
|
||
def test_get_slave_db(self): | ||
self.assertIn(get_slave_db(), settings.AIRONE['DB_SLAVES']) |
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
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
Oops, something went wrong.