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

feat: provision to enable/disable prepared report from permission for page and report document #6831

Conversation

rohitwaghchaure
Copy link
Contributor

@rohitwaghchaure rohitwaghchaure commented Jan 24, 2019

  1. Threshold time changed from 60 to 30 seconds which will auto enabled the prepared report
  2. Added provision to disable prepared report from the permission for page and report document

screen shot 2019-01-25 at 4 06 37 pm

  1. Added progress bar
    show_progress_bar

  2. Added report execution time in the report

screen shot 2019-01-25 at 3 57 11 pm

@rohitwaghchaure rohitwaghchaure force-pushed the provision_to_enable_prepared_report_from_permissions_page branch from 581849a to 38b47ef Compare January 25, 2019 04:46
@rmehta
Copy link
Member

rmehta commented Jan 25, 2019

it should be enabled by default. "Disable Prepared Report"?

Also will you add execution time and progress bar?

@rohitwaghchaure
Copy link
Contributor Author

Also will you add execution time and progress bar?
Yes, working on it

if not hasattr(frappe.local, 'is_prepared_report'):
frappe.local.is_prepared_report = {}

if not report in frappe.local.is_prepared_report:
Copy link
Contributor

Choose a reason for hiding this comment

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

I may be unclear on how the frappe.local object works, but if a report's prepared_report field is updated more than once in a session (either manually or by reaching the threshold), wouldn't this check not allow the frappe.local object to be modified, and always return the state it was initialised with?

@@ -19,7 +20,11 @@ def get_custom_roles(self):
roles = self.get_standard_roles()

self.set('roles', roles)


if self.report:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in a different function? Otherwise it's tied to get_custom_roles calls, which seems unrelated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in new function check_prepared_report_disabled

@@ -50,6 +55,9 @@ def set_custom_roles(self):
else:
frappe.get_doc(args).insert()

if self.report:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: should this be in a different function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


if self.report:
prepared_report = is_prepared_report(self.report)
self.set('enable_prepared_report', prepared_report)
Copy link
Contributor

Choose a reason for hiding this comment

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

Benefit of doing self.set(...) vs just self.enable_prepared_report = is_prepared_report(self.report)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@rohitwaghchaure rohitwaghchaure force-pushed the provision_to_enable_prepared_report_from_permissions_page branch 3 times, most recently from 1413423 to 2d3afa8 Compare January 25, 2019 10:14
@rohitwaghchaure rohitwaghchaure force-pushed the provision_to_enable_prepared_report_from_permissions_page branch from 2d3afa8 to b5f1cb0 Compare January 25, 2019 10:26
@rohitwaghchaure
Copy link
Contributor Author

@rmehta Added execution time and progress bar in the report

@rohitwaghchaure rohitwaghchaure force-pushed the provision_to_enable_prepared_report_from_permissions_page branch from b5f1cb0 to f17b476 Compare January 25, 2019 10:57
@rohitwaghchaure rohitwaghchaure force-pushed the provision_to_enable_prepared_report_from_permissions_page branch from f17b476 to c573cf1 Compare January 25, 2019 11:16
Copy link
Member

@rmehta rmehta left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@@ -193,3 +193,14 @@ def _format(parts):
@Document.whitelist
def toggle_disable(self, disable):
self.db_set("disabled", cint(disable))

@frappe.whitelist()
def is_prepared_report_disabled(report):
Copy link
Member

Choose a reason for hiding this comment

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

no need to cache!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the function is just a get_value call now. Might as well remove this function and do the call inline in the other file.

});
});

return this._load_script;
}

setup_progress_bar() {
let i = 0;
Copy link
Member

Choose a reason for hiding this comment

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

let seconds_elapsed = 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

const message = __('For comparison, use >5, <10 or =324. For ranges, use 5:10 (for values between 5 & 10).');
this.page.footer.removeClass('hide').addClass('text-muted text-center').html(`<p>${message}</p>`);
const execution_time_msg = __('Exection Time: {0} sec.', [this.execution_time || 0.1]);
Copy link
Member

Choose a reason for hiding this comment

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

period (.) not required after sec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!


this.interval = setInterval(function() {
i += 1;
frappe.show_progress(__('Loading Data'), i, execution_time);
Copy link
Member

Choose a reason for hiding this comment

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

__('Preparing Report')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@rohitwaghchaure rohitwaghchaure force-pushed the provision_to_enable_prepared_report_from_permissions_page branch from eefb329 to 36327f2 Compare January 29, 2019 07:44
@saurabh6790 saurabh6790 changed the base branch from staging-fixes to hotfix January 29, 2019 13:36
@rmehta rmehta merged commit e458d7d into frappe:hotfix Jan 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants