Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: move events serverside #2661

Closed
wants to merge 67 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f31e346
move events serverside
alison985 Jul 1, 2018
94fb2d9
Merge pull request #3 from getredash/master
alison985 Jul 4, 2018
5b0ea8c
updates to object_ids/types
alison985 Jul 8, 2018
133283a
first pass
alison985 Jul 10, 2018
f46e668
show only columns that match the search
alison985 Jul 13, 2018
c51edd3
Merge pull request #5 from getredash/master
alison985 Jul 22, 2018
4ac7ab8
move events serverside
alison985 Jul 1, 2018
2e748ce
updates to object_ids/types
alison985 Jul 8, 2018
89aa0d6
merge
alison985 Jul 22, 2018
ea91d91
Merge pull request #6 from getredash/master
alison985 Jul 30, 2018
5f352ef
Merge pull request #8 from StantonVentures/master
alison985 Aug 1, 2018
ff848f2
codeclimate: refactor for similar code
alison985 Aug 1, 2018
b2d57f8
gitignore additional migration & typo
alison985 Aug 1, 2018
bd34db6
Merge branch 'alison_2484' into master
alison985 Aug 1, 2018
86086a9
Revert "Merge branch 'alison_2484' into master"
alison985 Aug 1, 2018
6c8146c
Merge pull request #10 from getredash/master
alison985 Aug 12, 2018
a66d304
In docker-entrypoint ensure tables exist
Apr 12, 2017
f3c2e44
upgrade node and npm in dockerfile
alison985 Aug 11, 2017
2d189d5
Update Circle CI for our workflow
robotblake Apr 19, 2017
c09c41f
add pyup config document
alison985 Jul 8, 2017
033841c
Pin PyAthena dependency to 1.2.0.
jezdez Oct 25, 2017
7ea2f37
Switch to PyMySQL for MySQL 5.7 support
Sep 14, 2017
dc83652
upgrade to Celery 4.1.1
Jan 8, 2018
7614368
Documentation links for data sources (re #6)
Nov 8, 2016
167ea03
Don't execute query when changing data sources (fixes #29)
Feb 10, 2017
8f9e63d
Retry fetching query result on failure (fixes #36)
Feb 16, 2017
2c3149c
Use saved values for parameters in scheduled queries (re #43)
Feb 24, 2017
c8e9f42
Add `schedule_until` field to queries, to allow expiry (re #15)
Mar 2, 2017
e34b5b2
add compare query version support (re #7)
spasovski Feb 6, 2017
13b7bed
Filter tables from schema browser (re #31)
Jul 9, 2018
6b229a0
give warning/error msg on inaccurate graph config (re #57)
alison985 Jun 22, 2017
0a06222
add column type info to query runners (re #152, #23)
alison985 Jul 28, 2017
f4a349e
add hideParameters param (re #163)
alison985 Jul 28, 2017
ba80c43
add ability to add query to dashboard from query page (re #154)
alison985 Aug 8, 2017
ff55413
Add last_active_at column to users page (re #155)
alison985 Aug 12, 2017
8134845
add partition key marker to Athena and Presto columns (re #185)
Dec 9, 2017
145dd98
make autocomplete for large schemas faster (re #232)
Dec 9, 2017
9a587e8
Toggle for query editor autocomplete (re #282)
Dec 19, 2017
2dbde49
hide query more menu if empty (re #208)
spasovski Aug 17, 2017
9ed4815
Move events server side (re #245)
alison985 Sep 1, 2017
b3bc29d
server side
jezdez Aug 16, 2018
8f6597c
Run queries with no cached result in public dashboards (re #220)
Sep 6, 2017
f899a1b
allow x-axis label truncation (re #249)
Jul 9, 2018
65eff8d
secure cookies, add X-Content-Type-Options header (bug 1371613)
Sep 27, 2017
c87ec6a
Merge mozilla schema updates with schema from master
Dec 12, 2017
4add5bb
merge upstream db changes
Feb 14, 2018
105e798
Propagate query execution errors from Celery tasks properly (re #290)
Feb 27, 2018
16846d7
Support authentication for URL data source (re #330) (#336)
Mar 20, 2018
6f3d513
properly rollback failed db commits
Mar 21, 2018
016e4ac
Install redash-stmo.
jezdez Feb 28, 2018
dad916e
Extend the Remote User Auth backend with REMOTE_GROUPS ability (#311)
jezdez Mar 23, 2018
8c176cb
Unique names for query parameters (re #164)
Jan 16, 2018
e93385e
Aggregate query results (re #35) (#339)
Mar 27, 2018
c4b9a25
Updates to docker-entrypoint for worker and scheduler (#364)
jasonthomas Apr 11, 2018
2a09e2d
Closes #396: Integration with Flower.
May 11, 2018
c202a9a
merge upstream db changes
Jun 28, 2018
7a46113
Add data source health monitoring via an extension.
Apr 27, 2018
6377dcd
typo fixes for events
alison985 Aug 19, 2018
ae43558
Merge pull request #13 from mozilla/master
alison985 Aug 19, 2018
5497f0e
move events serverside
alison985 Jul 1, 2018
d9ae75b
updates to object_ids/types
alison985 Jul 8, 2018
ea4d2ab
move events serverside
alison985 Jul 1, 2018
9b16179
codeclimate: refactor for similar code
alison985 Aug 1, 2018
4b99223
gitignore additional migration & typo
alison985 Aug 1, 2018
c735de6
typo fixes for events
alison985 Aug 19, 2018
81287d1
Merge branch 'alison_1501' of https://github.com/StantonVentures/reda…
alison985 Aug 20, 2018
85727c1
fix codeclimate errors on files touched by this PR
alison985 Aug 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions client/app/components/dashboards/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ function DashboardWidgetCtrl($location, $uibModal, $window, Events, currentUser)
return;
}

Events.record('delete', 'widget', this.widget.id);

this.widget.delete().then(() => {
if (this.deleted) {
this.deleted({});
Expand Down
3 changes: 1 addition & 2 deletions client/app/pages/admin/outdated-queries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import moment from 'moment';
import { Paginator } from '@/lib/pagination';
import template from './outdated-queries.html';

function OutdatedQueriesCtrl($scope, Events, $http, $timeout) {
Events.record('view', 'page', 'admin/outdated_queries');
function OutdatedQueriesCtrl($scope, $http, $timeout) {
$scope.autoUpdate = true;

this.queries = new Paginator([], { itemsPerPage: 50 });
Expand Down
2 changes: 0 additions & 2 deletions client/app/pages/alert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function AlertCtrl($routeParams, $location, $sce, toastr, currentUser, Query, Ev

if (this.alertId === 'new') {
Events.record('view', 'page', 'alerts/new');
} else {
Events.record('view', 'alert', this.alertId);
}

this.trustAsHtml = html => $sce.trustAsHtml(html);
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/alerts-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const stateClass = {
};

class AlertsListCtrl {
constructor(Events, Alert) {
Events.record('view', 'page', 'alerts');

constructor(Alert) {
this.showEmptyState = false;
this.showList = false;

Expand Down
2 changes: 0 additions & 2 deletions client/app/pages/dashboards/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ function DashboardCtrl(
{ slug: $routeParams.dashboardSlug },
(dashboard) => {
this.dashboard = dashboard;
Events.record('view', 'dashboard', dashboard.id);
renderDashboard(dashboard, force);

if ($location.search().edit === true) {
Expand Down Expand Up @@ -227,7 +226,6 @@ function DashboardCtrl(

this.archiveDashboard = () => {
const archive = () => {
Events.record('archive', 'dashboard', this.dashboard.id);
this.dashboard.$delete(() => {
$rootScope.$broadcast('reloadDashboards');
});
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/data-sources/list.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import settingsMenu from '@/lib/settings-menu';
import template from './list.html';

function DataSourcesCtrl(Policy, Events, DataSource) {
Events.record('view', 'page', 'admin/data_sources');

function DataSourcesCtrl(Policy, DataSource) {
this.policy = Policy;
this.dataSources = DataSource.query();
}
Expand Down
8 changes: 1 addition & 7 deletions client/app/pages/data-sources/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const logger = debug('redash:http');

function DataSourceCtrl(
$scope, $route, $routeParams, $http, $location, toastr,
currentUser, AlertDialog, Events, DataSource,
currentUser, AlertDialog, DataSource,
) {
Events.record('view', 'page', 'admin/data_source');

$scope.dataSource = $route.current.locals.dataSource;
$scope.dataSourceId = $routeParams.dataSourceId;
$scope.types = $route.current.locals.types;
Expand Down Expand Up @@ -45,8 +43,6 @@ function DataSourceCtrl(

function deleteDataSource(callback) {
const doDelete = () => {
Events.record('delete', 'datasource', $scope.dataSource.id);

$scope.dataSource.$delete(() => {
toastr.success('Data source deleted successfully.');
$location.path('/data_sources/');
Expand All @@ -64,8 +60,6 @@ function DataSourceCtrl(
}

function testConnection(callback) {
Events.record('test', 'datasource', $scope.dataSource.id);

DataSource.test({ id: $scope.dataSource.id }, (httpResponse) => {
if (httpResponse.ok) {
toastr.success('Success');
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/destinations/list.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import settingsMenu from '@/lib/settings-menu';
import template from './list.html';

function DestinationsCtrl($scope, $location, toastr, currentUser, Events, Destination) {
Events.record('view', 'page', 'admin/destinations');

function DestinationsCtrl($scope, $location, toastr, currentUser, Destination) {
$scope.destinations = Destination.query();
}

Expand Down
6 changes: 1 addition & 5 deletions client/app/pages/destinations/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const logger = debug('redash:http');

function DestinationCtrl(
$scope, $route, $routeParams, $http, $location, toastr,
currentUser, AlertDialog, Events, Destination,
currentUser, AlertDialog, Destination,
) {
Events.record('view', 'page', 'admin/destination');

$scope.destination = $route.current.locals.destination;
$scope.destinationId = $routeParams.destinationId;
$scope.types = $route.current.locals.types;
Expand All @@ -34,8 +32,6 @@ function DestinationCtrl(

$scope.delete = () => {
const doDelete = () => {
Events.record('delete', 'destination', $scope.destination.id);

$scope.destination.$delete(() => {
toastr.success('Destination deleted successfully.');
$location.path('/destinations/');
Expand Down
3 changes: 1 addition & 2 deletions client/app/pages/groups/data-sources.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { includes } from 'lodash';
import template from './data-sources.html';

function GroupDataSourcesCtrl($scope, $routeParams, $http, Events, Group, DataSource) {
Events.record('view', 'group_data_sources', $scope.groupId);
function GroupDataSourcesCtrl($scope, $routeParams, $http, Group, DataSource) {
$scope.group = Group.get({ id: $routeParams.groupId });
$scope.dataSources = Group.dataSources({ id: $routeParams.groupId });
$scope.newDataSource = {};
Expand Down
3 changes: 1 addition & 2 deletions client/app/pages/groups/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import settingsMenu from '@/lib/settings-menu';
import { Paginator } from '@/lib/pagination';
import template from './list.html';

function GroupsCtrl($scope, $uibModal, currentUser, Events, Group) {
Events.record('view', 'page', 'groups');
function GroupsCtrl($scope, $uibModal, currentUser, Group) {
$scope.currentUser = currentUser;
$scope.groups = new Paginator([], { itemsPerPage: 20 });
Group.query((groups) => {
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/groups/show.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { includes } from 'lodash';
import template from './show.html';

function GroupCtrl($scope, $routeParams, $http, currentUser, Events, Group, User) {
Events.record('view', 'group', $scope.groupId);

function GroupCtrl($scope, $routeParams, $http, currentUser, Group, User) {
$scope.currentUser = currentUser;
$scope.group = Group.get({ id: $routeParams.groupId });
$scope.members = Group.members({ id: $routeParams.groupId });
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/queries/queries-search-results-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isString } from 'lodash';
import { Paginator } from '@/lib/pagination';
import template from './queries-search-results-page.html';

function QuerySearchCtrl($location, $filter, currentUser, Events, Query) {
function QuerySearchCtrl($location, $filter, currentUser, Query) {
this.term = $location.search().q;
this.paginator = new Paginator([], { itemsPerPage: 20 });

Expand Down Expand Up @@ -46,8 +46,6 @@ function QuerySearchCtrl($location, $filter, currentUser, Events, Query) {
$location.search({ q: this.term });
}
};

Events.record('search', 'query', '', { term: this.term });
}

export default function init(ngModule) {
Expand Down
5 changes: 0 additions & 5 deletions client/app/pages/queries/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function QueryViewCtrl(
KeyboardShortcuts.unbind(shortcuts);
});

Events.record('view', 'query', $scope.query.id);
if ($scope.query.hasResult() || $scope.query.paramsRequired()) {
getQueryResult();
}
Expand Down Expand Up @@ -178,8 +177,6 @@ function QueryViewCtrl(
};

$scope.duplicateQuery = () => {
Events.record('fork', 'query', $scope.query.id);

Query.fork({ id: $scope.query.id }, (newQuery) => {
$location.url(newQuery.getSourceLink()).replace();
});
Expand Down Expand Up @@ -326,8 +323,6 @@ function QueryViewCtrl(
const confirm = { class: 'btn-danger', title: 'Delete' };

AlertDialog.open(title, message, confirm).then(() => {
Events.record('delete', 'visualization', vis.id);

Visualization.delete({ id: vis.id }, () => {
if ($scope.selectedTab === String(vis.id)) {
$scope.selectedTab = DEFAULT_TAB;
Expand Down
3 changes: 1 addition & 2 deletions client/app/pages/query-snippets/edit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'brace/mode/snippets';
import template from './edit.html';

function SnippetCtrl($routeParams, $http, $location, toastr, currentUser, AlertDialog, Events, QuerySnippet) {
function SnippetCtrl($routeParams, $http, $location, toastr, currentUser, AlertDialog, QuerySnippet) {
this.snippetId = $routeParams.snippetId;
Events.record('view', 'query_snippet', this.snippetId);

this.editorOptions = {
mode: 'snippets',
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/query-snippets/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import settingsMenu from '@/lib/settings-menu';
import { Paginator } from '@/lib/pagination';
import template from './list.html';

function SnippetsCtrl($location, currentUser, Events, QuerySnippet) {
Events.record('view', 'page', 'query_snippets');

function SnippetsCtrl($location, currentUser, QuerySnippet) {
this.snippets = new Paginator([], { itemsPerPage: 20 });
QuerySnippet.query((snippets) => {
this.snippets.updateRows(snippets);
Expand Down
4 changes: 1 addition & 3 deletions client/app/pages/users/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import settingsMenu from '@/lib/settings-menu';
import { Paginator } from '@/lib/pagination';
import template from './list.html';

function UsersCtrl(currentUser, Policy, Events, User) {
Events.record('view', 'page', 'users');

function UsersCtrl(currentUser, Policy, User) {
this.currentUser = currentUser;
this.policy = Policy;
this.users = new Paginator([], { itemsPerPage: 20 });
Expand Down
3 changes: 1 addition & 2 deletions client/app/pages/users/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import './settings.less';

function UserCtrl(
$scope, $routeParams, $http, $location, toastr,
clientConfig, currentUser, Events, User,
clientConfig, currentUser, User,
) {
$scope.userId = $routeParams.userId;
$scope.currentUser = currentUser;
Expand All @@ -16,7 +16,6 @@ function UserCtrl(
$scope.userId = currentUser.id;
}

Events.record('view', 'user', $scope.userId);
$scope.canEdit = currentUser.hasPermission('admin') || currentUser.id === parseInt($scope.userId, 10);
$scope.showSettings = false;
$scope.showPasswordSettings = false;
Expand Down
15 changes: 15 additions & 0 deletions redash/handlers/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import time

from flask import request
from flask_login import login_required
Expand All @@ -7,6 +8,7 @@
from redash.handlers.base import json_response
from redash.permissions import require_super_admin
from redash.tasks.queries import QueryTaskTracker
from redash.tasks import record_event


@routes.route('/api/admin/queries/outdated', methods=['GET'])
Expand All @@ -23,6 +25,13 @@ def outdated_queries():
else:
outdated_queries = []

record_event({
'action': 'view',
'object_type': 'api_call',
'object_id': 'admin/outdated_queries',
'timestamp': int(time.time()),
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action -> list
object_type -> outdated_queries

(object_id can be null and can be ommited)


return json_response(
dict(queries=[q.to_dict(with_stats=True, with_last_modified_by=False)
for q in outdated_queries],
Expand All @@ -33,6 +42,12 @@ def outdated_queries():
@require_super_admin
@login_required
def queries_tasks():
record_event({
'action': 'view',
'object_type': 'api_call',
'object_id': 'admin/tasks',
'timestamp': int(time.time()),
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action -> list
object_type -> celery_tasks

global_limit = int(request.args.get('limit', 50))
waiting_limit = int(request.args.get('waiting_limit', global_limit))
progress_limit = int(request.args.get('progress_limit', global_limit))
Expand Down
12 changes: 12 additions & 0 deletions redash/handlers/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class AlertResource(BaseResource):
def get(self, alert_id):
alert = get_object_or_404(models.Alert.get_by_id_and_org, alert_id, self.current_org)
require_access(alert.groups, self.current_user, view_only)
self.record_event({
'action': 'view',
'timestamp': int(time.time()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp is being added by self.record_event,so no need to pass it manually (of course this applies in all other similar instances).

'object_id': alert.id,
'object_type': 'alert'
})
return alert.to_dict()

def post(self, alert_id):
Expand Down Expand Up @@ -73,6 +79,12 @@ def post(self):

@require_permission('list_alerts')
def get(self):
self.record_event({
'action': 'view',
'timestamp': int(time.time()),
'object_id': 'alerts',
'object_type': 'api_call'
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's convert all the list actions, where you used object_type=api_call to:

action -> list
object_type -> <the relevant resource type> (in this case it will be alert, to be consistent with the other events for this type).

return [alert.to_dict() for alert in models.Alert.all(group_ids=self.current_user.group_ids)]


Expand Down
16 changes: 16 additions & 0 deletions redash/handlers/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def get(self, dashboard_slug=None):

response['can_edit'] = can_modify(dashboard, self.current_user)

self.record_event({
'action': 'view',
'object_id': dashboard.id,
'object_type': 'dashboard',
})

return response

@require_permission('edit_dashboard')
Expand Down Expand Up @@ -147,6 +153,11 @@ def post(self, dashboard_slug):
abort(409)

result = dashboard.to_dict(with_widgets=True, user=self.current_user)
self.record_event({
'action': 'edit',
'object_id': dashboard.id,
'object_type': 'dashboard',
})
return result

@require_permission('edit_dashboard')
Expand All @@ -164,6 +175,11 @@ def delete(self, dashboard_slug):
models.db.session.add(dashboard)
d = dashboard.to_dict(with_widgets=True, user=self.current_user)
models.db.session.commit()
self.record_event({
'action': 'archive',
'object_id': dashboard.id,
'object_type': 'dashboard',
})
return d


Expand Down
Loading