Skip to content

Commit

Permalink
Merge pull request #3165 from SEED-platform/fix/lint-fixes
Browse files Browse the repository at this point in the history
Lint fixes
  • Loading branch information
axelstudios committed Mar 15, 2022
2 parents a93f8f3 + 6506172 commit c5a3288
Show file tree
Hide file tree
Showing 43 changed files with 661 additions and 666 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018
},
"env": {
"browser": true,
"es6": true,
Expand Down Expand Up @@ -66,7 +69,6 @@
"lodash/prefer-filter": ["warn", 3],
"lodash/prefer-get": ["warn", 2],
"lodash/prefer-is-nil": "warn",
"lodash/prefer-lodash-typecheck": "warn",
"lodash/prefer-matches": ["warn", 2],
"lodash/prefer-startswith": "warn",
"lodash/prefer-times": "warn",
Expand Down
8 changes: 4 additions & 4 deletions docker/backup_k8s/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Author: Nicholas Long
#
# This docker container is used to create a backup of the seed database and
#
# This docker container is used to create a backup of the seed database and
# mediafiles, then push the backups to S3. The script itself is the backup_database.sh
# script that is copied into this container for use by helm/k8s batch/CronJob.

Expand All @@ -22,7 +22,7 @@ RUN apt update && \
apt upgrade -y && \
apt install -y \
python3 \
curl \
curl \
apt-transport-https \
ca-certificates \
gnupg \
Expand All @@ -36,6 +36,6 @@ RUN apt update && \
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
apt update && \
apt install -y postgresql-client-12

WORKDIR /app
ADD backup_database.sh /app/
6 changes: 3 additions & 3 deletions seed/docs/static/docs/js/faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ angular.module('BE.docs.controller.faq', [])
function ($scope, $timeout) {
// faq-data must be a script JSON element templated into the page
const faqScript = angular.element('#faq-data')[0];
if (!faqScript) {
console.error('Failed to find FAQ data with id faq-data. Ensure it is inserted before the controller is used.');
}
// if (!faqScript) {
// console.error('Failed to find FAQ data with id faq-data. Ensure it is inserted before the controller is used.');
// }

// Autofocus on the input
angular.element('.faq-search-input')[0].focus();
Expand Down
2 changes: 1 addition & 1 deletion seed/lib/xml_mapping/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, file_):
"""
:param file_: FieldFile, an ImportFile's file
"""
# these properties will be construced while processing the files
# these properties will be constructed while processing the files
self.headers = []
self._xpath_col_dict = {}

Expand Down
4 changes: 1 addition & 3 deletions seed/static/seed/js/controllers/admin_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ angular.module('BE.seed.controller.admin', [])
'users_payload',
'Notification',
'$window',
'urls',
function (
$scope,
$log,
Expand All @@ -31,8 +30,7 @@ angular.module('BE.seed.controller.admin', [])
user_profile_payload,
users_payload,
Notification,
$window,
urls
$window
) {
$scope.is_superuser = auth_payload.auth.requires_superuser;
$scope.user = {};
Expand Down
56 changes: 28 additions & 28 deletions seed/static/seed/js/controllers/analyses_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ angular.module('BE.seed.controller.analyses', [])
auth_payload,
urls,
analyses_service,
Notification,
Notification
) {
$scope.org = organization_payload;
$scope.auth = auth_payload.auth;
$scope.analyses = analyses_payload.analyses;
$scope.users = users_payload.users;

// Stores functions for stopping the polling of analysis progress. Keyed by analysis id
const analysis_polling_stoppers = {}
const analysis_polling_stoppers = {};

$scope.$on('$destroy', () => {
// cancel all polling
Object.values(analysis_polling_stoppers).forEach(stop_func => stop_func())
})
Object.values(analysis_polling_stoppers).forEach(stop_func => stop_func());
});

const refresh_analyses = function () {
analyses_service.get_analyses_for_org($scope.org.id)
Expand All @@ -48,37 +48,37 @@ angular.module('BE.seed.controller.analyses', [])
return analyses_service.get_analysis_for_org(analysis_id, $scope.org.id)
.then(data => {
const analysis_index = $scope.analyses.findIndex(analysis => {
return analysis.id === analysis_id
})
$scope.analyses[analysis_index] = data.analysis
return data.analysis
})
}
return analysis.id === analysis_id;
});
$scope.analyses[analysis_index] = data.analysis;
return data.analysis;
});
};

// add flag to the analysis indicating it has no currently running tasks
// Used to determine if we should indicate on UI if an analysis's status is being polled
const mark_analysis_not_active = (analysis_id) => {
const analysis_index = $scope.analyses.findIndex(analysis => {
return analysis.id === analysis_id
})
$scope.analyses[analysis_index]._finished_with_tasks = true
}
return analysis.id === analysis_id;
});
$scope.analyses[analysis_index]._finished_with_tasks = true;
};

// Entry point for keeping track of analysis progress
// Refreshes analysis in $scope when necessary
const poll_analysis_progress = (analysis) => {
if (analysis_polling_stoppers[analysis.id]) {
analysis_polling_stoppers[analysis.id]()
analysis_polling_stoppers[analysis.id]();
}

const stop_func = analyses_service.check_progress_loop(analysis, refresh_analysis, mark_analysis_not_active)
analysis_polling_stoppers[analysis.id] = stop_func
}
const stop_func = analyses_service.check_progress_loop(analysis, refresh_analysis, mark_analysis_not_active);
analysis_polling_stoppers[analysis.id] = stop_func;
};

// start polling all of the analyses
$scope.analyses.forEach(analysis => {
poll_analysis_progress(analysis)
})
poll_analysis_progress(analysis);
});

$scope.start_analysis = function (analysis_id) {
const analysis = $scope.analyses.find(function (a) {
Expand All @@ -92,8 +92,8 @@ angular.module('BE.seed.controller.analyses', [])
Notification.primary('Analysis started');
refresh_analysis(analysis_id)
.then((updated_analysis) => {
poll_analysis_progress(updated_analysis)
})
poll_analysis_progress(updated_analysis);
});
} else {
Notification.error('Failed to start analysis: ' + result.message);
}
Expand All @@ -112,8 +112,8 @@ angular.module('BE.seed.controller.analyses', [])
Notification.primary('Analysis stopped');
refresh_analysis(analysis_id)
.then((updated_analysis) => {
poll_analysis_progress(updated_analysis)
})
poll_analysis_progress(updated_analysis);
});
} else {
Notification.error('Failed to stop analysis: ' + result.message);
}
Expand All @@ -131,11 +131,11 @@ angular.module('BE.seed.controller.analyses', [])
if (result.status === 'success') {
Notification.primary('Analysis deleted');
// stop polling and remove the analysis from the scope
analysis_polling_stoppers[analysis_id]()
analysis_polling_stoppers[analysis_id]();
const analysis_index = $scope.analyses.findIndex(analysis => {
return analysis.id === analysis_id
})
$scope.analyses.splice(analysis_index, 1)
return analysis.id === analysis_id;
});
$scope.analyses.splice(analysis_index, 1);
} else {
Notification.error('Failed to delete analysis: ' + result.message);
}
Expand Down
26 changes: 13 additions & 13 deletions seed/static/seed/js/controllers/analysis_details_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ angular.module('BE.seed.controller.analysis_details', [])
$state,
analyses_service
) {
let stop_func = () => {}
const starting_analysis_status = $scope.analysis.status
let stop_func = () => {};
const starting_analysis_status = $scope.analysis.status;

$scope.$on('$destroy', () => {
stop_func()
})
stop_func();
});

const refresh_analysis = (analysis_id) => {
// update analysis in scope
return analyses_service.get_analysis_for_org(analysis_id, $scope.org.id)
.then(data => {
$scope.analysis = data.analysis
return data.analysis
})
}
$scope.analysis = data.analysis;
return data.analysis;
});
};

// add flag to the analysis indicating it has no currently running tasks
// Used to determine if we should indicate on UI if an analysis's status is being polled
const mark_analysis_not_active = (analysis_id) => {
$scope.analysis._finished_with_tasks = true
const mark_analysis_not_active = (/*analysis_id*/) => {
$scope.analysis._finished_with_tasks = true;

// if the status of the analysis has changed since we first loaded the page, refresh everything
// so that analysis results and messages are updated. (this is lazy, but is good enough for now)
if (starting_analysis_status != $scope.analysis.status) {
$state.reload()
$state.reload();
}
}
};

stop_func = analyses_service.check_progress_loop($scope.analysis, refresh_analysis, mark_analysis_not_active)
stop_func = analyses_service.check_progress_loop($scope.analysis, refresh_analysis, mark_analysis_not_active);
}]);
6 changes: 3 additions & 3 deletions seed/static/seed/js/controllers/analysis_run_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ angular.module('BE.seed.controller.analysis_run', [])
// Forces analysis_runs.html to only show one view/run - the selected run
$scope.views = [view_payload.view];
$scope.view = view_payload.view;
if ($scope.analysis.service == 'BETTER') {
if ($scope.analysis.service === 'BETTER') {
// for BETTER, make sure we show the Building report before the Portfolio report
$scope.view.output_files.sort((a, b) => a.file.includes('portfolio') ? 1 : -1)
$scope.view.output_files.sort(a => a.file.includes('portfolio') ? 1 : -1);
}
$scope.view_id = view_payload.view.id;
$scope.original_view = view_payload.original_view;
Expand All @@ -58,6 +58,6 @@ angular.module('BE.seed.controller.analysis_run', [])
// NOTE: hardcoding 'property' b/c you can only run analyses on properties
'property',
inventory_state
)
);
};
}]);
4 changes: 2 additions & 2 deletions seed/static/seed/js/controllers/cycle_admin_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ angular.module('BE.seed.controller.cycle_admin', [])
cycle: (organization_service) => {
return organization_service.get_organization($scope.org.id)
.then(res => {
return res.organization.cycles.find(cycle => cycle.cycle_id == cycle_id)
})
return res.organization.cycles.find(cycle => cycle.cycle_id == cycle_id);
});
},
organization_id: () => $scope.org.id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ angular.module('BE.seed.controller.data_quality_admin', [])
column_name: derived_column.name,
displayName: derived_column.name,
group: 'Derived',
is_derived: true,
}
}))
is_derived: true
};
}));

// if (flippers.is_active('release:orig_columns')) {
// // db may return _orig columns; don't suggest them in the select
Expand Down Expand Up @@ -268,7 +268,7 @@ angular.module('BE.seed.controller.data_quality_admin', [])
severity: rule.severity,
units: rule.units,
status_label: null,
for_derived_column: !!column.is_derived,
for_derived_column: !!column.is_derived
};
if (rule.condition === 'not_null' || rule.condition === 'required') {
r.min = null;
Expand Down

0 comments on commit c5a3288

Please sign in to comment.