Events table name and start/end dates should not be necessary for SummaryDashboard.

This commit is contained in:
Marina Samuel 2019-02-08 10:23:10 -05:00
Родитель 07f9a9c73a
Коммит f594d6585e
4 изменённых файлов: 13 добавлений и 22 удалений

Просмотреть файл

@ -1,3 +1,4 @@
import time
import logging
from redash_client.constants import VizWidth
@ -38,21 +39,26 @@ class ExperimentDashboard(SummaryDashboard):
RETENTION_DIFF_TITLE = "Daily Retention Difference (Experiment - Control)"
def __init__(self, api_key, project_name, dash_name, exp_id,
start_date=None, end_date=None):
start_date, end_date=None, events_table_name=None):
DASH_TITLE = "{project}: {dash}".format(
project=project_name, dash=dash_name)
super(ExperimentDashboard, self).__init__(
api_key,
DASH_TITLE,
self.DEFAULT_EVENTS_TABLE,
start_date, end_date)
DASH_TITLE)
logging.basicConfig()
self._logger = logging.getLogger()
self._logger.setLevel(logging.INFO)
self._experiment_id = exp_id
self._start_date = start_date
self._end_date = end_date if end_date else time.strftime("%Y-%m-%d")
self._events_table = events_table_name or self.DEFAULT_EVENTS_TABLE
self._params = {
"start_date": self._start_date,
"end_date": self._end_date,
"experiment_id": self._experiment_id
}
self._params["experiment_id"] = self._experiment_id
self._logger.info((
"ExperimentDashboard: {name} "
"Initialization Complete".format(name=dash_name)))

Просмотреть файл

@ -1,5 +1,3 @@
import time
from datetime import datetime
from dateutil.parser import parse
from redash_client.client import RedashClient
@ -12,16 +10,8 @@ class SummaryDashboard(object):
class ExternalAPIError(Exception):
pass
def __init__(self, api_key, dash_name, events_table_name,
start_date, end_date=None):
def __init__(self, api_key, dash_name):
self._dash_name = dash_name
self._events_table = events_table_name
self._start_date = start_date
self._end_date = end_date if end_date else time.strftime("%Y-%m-%d")
self._params = {
"start_date": self._start_date,
"end_date": self._end_date
}
try:
self.redash = RedashClient(api_key)

Просмотреть файл

@ -37,10 +37,7 @@ class AppTest(unittest.TestCase):
return response
def get_dashboard(self, api_key):
EVENTS_TABLE_NAME = "activity_stream_mobile_events_daily"
START_DATE = "02/17/2017"
DASH_NAME = "Firefox iOS: Metrics Summary"
EXPECTED_QUERY_ID = "query_id123"
EXPECTED_SLUG = "some_slug_it_made"
QUERY_ID_RESPONSE = {
@ -55,8 +52,6 @@ class AppTest(unittest.TestCase):
dashboard = SummaryDashboard(
self.API_KEY,
DASH_NAME,
EVENTS_TABLE_NAME,
START_DATE,
)
return dashboard

Просмотреть файл

@ -15,7 +15,7 @@ class TestSummaryDashboard(AppTest):
self.assertRaisesRegexp(
self.dash.ExternalAPIError,
"Unable to create new dashboard",
lambda: SummaryDashboard("a", "b", "c", "d",))
lambda: SummaryDashboard("a", "b",))
def test_add_visualization_to_dash_exception_thrown(self):
self._setupMockRedashClientException("add_visualization_to_dashboard")