Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AmendsenProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shaik Janipasha
AmendsenProject
Commits
97277402
Unverified
Commit
97277402
authored
Mar 03, 2020
by
Jin Hyuk Chang
Committed by
GitHub
Mar 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mode Dashboard last successful execution (#205)
* Mode Dashboard last successful execution * Increment version
parent
33fd3bef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
2 deletions
+64
-2
mode_dashboard_last_successful_executions_extractor.py
...cs/mode_dashboard_last_successful_executions_extractor.py
+59
-0
dashboard_execution.py
databuilder/models/dashboard/dashboard_execution.py
+4
-1
setup.py
setup.py
+1
-1
No files found.
databuilder/extractor/dashboard/mode_analytics/mode_dashboard_last_successful_executions_extractor.py
0 → 100644
View file @
97277402
import
logging
from
pyhocon
import
ConfigTree
,
ConfigFactory
# noqa: F401
from
databuilder.extractor.dashboard.mode_analytics.mode_dashboard_executions_extractor
import
\
ModeDashboardExecutionsExtractor
from
databuilder.extractor.dashboard.mode_analytics.mode_dashboard_utils
import
ModeDashboardUtils
from
databuilder.extractor.restapi.rest_api_extractor
import
STATIC_RECORD_DICT
from
databuilder.models.dashboard.dashboard_execution
import
DashboardExecution
from
databuilder.rest_api.rest_api_query
import
RestApiQuery
LOGGER
=
logging
.
getLogger
(
__name__
)
class
ModeDashboardLastSuccessfulExecutionExtractor
(
ModeDashboardExecutionsExtractor
):
"""
A Extractor that extracts Mode dashboard's last successful run (execution) timestamp.
"""
def
__init__
(
self
):
super
(
ModeDashboardLastSuccessfulExecutionExtractor
,
self
)
.
__init__
()
def
init
(
self
,
conf
):
# type: (ConfigTree) -> None
conf
=
conf
.
with_fallback
(
ConfigFactory
.
from_dict
({
STATIC_RECORD_DICT
:
{
'product'
:
'mode'
,
'execution_state'
:
'succeeded'
,
'execution_id'
:
DashboardExecution
.
LAST_SUCCESSFUL_EXECUTION_ID
}
})
)
super
(
ModeDashboardLastSuccessfulExecutionExtractor
,
self
)
.
init
(
conf
)
def
get_scope
(
self
):
# type: () -> str
return
'extractor.mode_dashboard_last_successful_execution'
def
_build_restapi_query
(
self
):
"""
Build REST API Query. To get Mode Dashboard last successful execution, it needs to call two APIs (spaces API,
and reports API) joining together.
:return: A RestApiQuery that provides Mode Dashboard last successful execution (run)
"""
# type: () -> RestApiQuery
spaces_query
=
ModeDashboardUtils
.
get_spaces_query_api
(
conf
=
self
.
_conf
)
params
=
ModeDashboardUtils
.
get_auth_params
(
conf
=
self
.
_conf
)
# Reports
# https://mode.com/developer/api-reference/analytics/reports/#listReportsInSpace
url
=
'https://app.mode.com/api/{organization}/spaces/{dashboard_group_id}/reports'
json_path
=
'_embedded.reports[*].[token,last_successfully_run_at]'
field_names
=
[
'dashboard_id'
,
'execution_timestamp'
]
last_successful_run_query
=
RestApiQuery
(
query_to_join
=
spaces_query
,
url
=
url
,
params
=
params
,
json_path
=
json_path
,
field_names
=
field_names
,
skip_no_result
=
True
)
return
last_successful_run_query
databuilder/models/dashboard/dashboard_execution.py
View file @
97277402
...
...
@@ -20,12 +20,15 @@ class DashboardExecution(Neo4jCsvSerializable):
DASHBOARD_EXECUTION_RELATION_TYPE
=
'LAST_EXECUTED'
EXECUTION_DASHBOARD_RELATION_TYPE
=
'LAST_EXECUTION_OF'
LAST_EXECUTION_ID
=
'_last_execution'
LAST_SUCCESSFUL_EXECUTION_ID
=
'_last_successful_execution'
def
__init__
(
self
,
dashboard_group_id
,
# type: Optional[str]
dashboard_id
,
# type: Optional[str]
execution_timestamp
,
# type: int
execution_state
,
# type: str
execution_id
=
'_last_execution'
,
# type: str
execution_id
=
LAST_EXECUTION_ID
,
# type: str
product
=
''
,
# type: Optional[str]
cluster
=
'gold'
,
# type: str
**
kwargs
...
...
setup.py
View file @
97277402
...
...
@@ -2,7 +2,7 @@ import os
from
setuptools
import
setup
,
find_packages
__version__
=
'2.
0.3
'
__version__
=
'2.
1.0
'
requirements_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'requirements.txt'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment