parent
7a5373c91e
commit
ba2c0c4fab
|
@ -19,6 +19,7 @@ import glob
|
|||
import json
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.db import connection
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
@ -26,6 +27,8 @@ from .schemas import Warehouse
|
|||
|
||||
|
||||
def get_warehouses():
|
||||
if cache.get('warehouses_cache'):
|
||||
return cache.get('warehouses_cache')
|
||||
warehouses = []
|
||||
for pattern in settings.BIJOE_SCHEMAS:
|
||||
for path in glob.glob(pattern):
|
||||
|
@ -34,6 +37,7 @@ def get_warehouses():
|
|||
pattern = os.path.join(connection.tenant.get_directory(), 'schemas', '*.model')
|
||||
for path in glob.glob(pattern):
|
||||
warehouses.append(Warehouse.from_json(json.load(open(path))))
|
||||
cache.set('warehouses_cache', warehouses, 30)
|
||||
return warehouses
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import psycopg2
|
|||
|
||||
from django.db import connection
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.cache import cache
|
||||
from django.core.management import call_command
|
||||
|
||||
|
||||
|
@ -52,6 +53,7 @@ SCHEMA_PATHS = os.path.join(os.path.dirname(__file__), 'fixtures/')
|
|||
def load_schema_db(schema):
|
||||
import random
|
||||
|
||||
cache.delete('warehouses_cache')
|
||||
database_name = 'db%s' % random.getrandbits(20)
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
bijoe_schema_dir = os.path.join(tmpdir, 'schemas')
|
||||
|
|
Loading…
Reference in New Issue