-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 #219 from EverythingMe/celery
Split __init__ into several modules and remove flask-peewee dependency.
- Loading branch information
Showing
13 changed files
with
121 additions
and
88 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
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
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 @@ | ||
from celery import Celery | ||
from datetime import timedelta | ||
from redash import settings | ||
|
||
|
||
celery = Celery('redash', | ||
broker=settings.CELERY_BROKER, | ||
include='redash.tasks') | ||
|
||
celery.conf.update(CELERY_RESULT_BACKEND=settings.CELERY_BACKEND, | ||
CELERYBEAT_SCHEDULE={ | ||
'refresh_queries': { | ||
'task': 'redash.tasks.refresh_queries', | ||
'schedule': timedelta(seconds=30) | ||
}, | ||
}, | ||
CELERY_TIMEZONE='UTC') | ||
|
||
|
||
if __name__ == '__main__': | ||
celery.start() |
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,32 @@ | ||
import json | ||
from flask import Flask, make_response | ||
from flask.ext.restful import Api | ||
|
||
from redash import settings, utils | ||
from redash.models import db | ||
|
||
__version__ = '0.4.0' | ||
|
||
app = Flask(__name__, | ||
template_folder=settings.STATIC_ASSETS_PATH, | ||
static_folder=settings.STATIC_ASSETS_PATH, | ||
static_path='/static') | ||
|
||
|
||
api = Api(app) | ||
|
||
# configure our database | ||
settings.DATABASE_CONFIG.update({'threadlocals': True}) | ||
app.config['DATABASE'] = settings.DATABASE_CONFIG | ||
db.init_app(app) | ||
|
||
from redash.authentication import setup_authentication | ||
auth = setup_authentication(app) | ||
|
||
@api.representation('application/json') | ||
def json_representation(data, code, headers=None): | ||
resp = make_response(json.dumps(data, cls=utils.JSONEncoder), code) | ||
resp.headers.extend(headers or {}) | ||
return resp | ||
|
||
from redash import controllers |
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 |
---|---|---|
@@ -1,28 +1,21 @@ | ||
import logging | ||
from unittest import TestCase | ||
from redash import settings, db, app | ||
import redash.models | ||
|
||
# TODO: this isn't pretty... | ||
from redash import settings | ||
settings.DATABASE_CONFIG = { | ||
'name': 'circle_test', | ||
'engine': 'peewee.PostgresqlDatabase', | ||
'threadlocals': True | ||
} | ||
app.config['DATABASE'] = settings.DATABASE_CONFIG | ||
db.load_database() | ||
|
||
logging.getLogger('peewee').setLevel(logging.INFO) | ||
from redash import models | ||
|
||
for model in redash.models.all_models: | ||
model._meta.database = db.database | ||
logging.getLogger('peewee').setLevel(logging.INFO) | ||
|
||
|
||
class BaseTestCase(TestCase): | ||
def setUp(self): | ||
redash.models.create_db(True, True) | ||
redash.models.init_db() | ||
models.create_db(True, True) | ||
models.init_db() | ||
|
||
def tearDown(self): | ||
db.close_db(None) | ||
redash.models.create_db(False, True) | ||
models.db.close_db(None) | ||
models.create_db(False, True) |
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