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

Fix notifications popup issues #980

Merged
merged 64 commits into from
Oct 23, 2018
Merged

Conversation

vantonov1
Copy link
Contributor

No description provided.

@vantonov1 vantonov1 requested a review from pavgra October 5, 2018 09:51
@pavgra
Copy link
Contributor

pavgra commented Oct 5, 2018

@vantonov1 ,

  1. Fix indentation - tabs should be used
  2. Use /services/http.js instead of $.ajax
  3. Why is jobListing still here if we talked about relying on back-end status? What is going to happen if I refresh page - all notifications gone?

@vantonov1
Copy link
Contributor Author

3 jobListing is the model for the notifications table, and where are subscribers to jobListing updates
On page refresh notifications are reloaded from backend

@pavgra
Copy link
Contributor

pavgra commented Oct 5, 2018

@vantonov1 , if back-end is the single source of truth - why do have lines like sharedState.jobListing.queue(job);?

  1. Why commented out lines were not removed?
// this.pollForInfo();
// executionId: String(this.model.currentCohortDefinition().id()) + String(this.getSourceId(source.sourceKey)),

@vantonov1
Copy link
Contributor Author

Not exactly. Backend is polled, it happens not often, so first notification (with PENDING state usually) is added on UI, and then updated from backend

4 Yes, it have to be removed

job.name = info.data.jobParameters.jobName;
job.executionId = info.data.executionId;
job.status(info.data.status);
sharedState.jobListing.queue(job);
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. The 4 lines of code above look exactly the same way as they do in negative-controls.js. Why not to move it to util method?
  2. Why queue here is called outside of timeout function (which seems to be the proper way), while above - inside the timeout?

@@ -85,7 +85,7 @@ define([
this.selectedAnalysisId.subscribe((id) => {
authAPI.loadUserInfo();
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Dummy diff

jobDetails.name = info.data.jobParameters.jobName;
jobDetails.executionId = info.data.executionId;
jobDetails.status(info.data.status);
sharedState.jobListing.queue(jobDetails);
Copy link
Contributor

Choose a reason for hiding this comment

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

Get a look at the comment above regarding shared util method

jobDetails.executionId = info.data.executionId;
jobDetails.status(info.data.status);
sharedState.jobListing.queue(jobDetails);
this.pollForInfo();
Copy link
Contributor

Choose a reason for hiding this comment

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

The same as above

@pavgra
Copy link
Contributor

pavgra commented Oct 5, 2018

Not exactly. Backend is polled, it happens not often, so first notification (with PENDING state usually) is added on UI, and then updated from backend

@vantonov1 , wouldn't it be better just throw event / call a method to pull the list of notifications when required but not to maintain two lists (versions) of the notifications?

@vantonov1
Copy link
Contributor Author

it costs additional server call. After success call to start a job, server returns just enough info to update notifications list - we just add new job to the list, there is no 2 versions. I dont think it is worth to ignore returned info, and ask again

@chrisknoll
Copy link
Collaborator

I'm in agreement with @vantonov1 : this is how it works (or used to work? Haven't checked if refactor changed this behavior) in cohort definition generation. The reason: if we rely on the polling to update the status of the generation, and the polling is at 10s intervals, if you post the generate request at second 1 of 10, you have to wait 9 whole seconds to see the UI respond to your generation request. What do users do when they don't see an immediate result of their button click? they click it again. How many clicks can you fit in 9 seconds? A lot (you should see me play starcraft). So, instead, the approach is to get the button click, disable the button, do the async post, get the response, read the status of the job or just populate the job list with a fake (but have the jobID from the initial POST to get the identifier of the job) and then subsequent polls will deliver the up-to-date state.

@pavgra
Copy link
Contributor

pavgra commented Oct 5, 2018

@chrisknoll , if you read my previous message, you'd see that you will NOT

have to wait 9 whole seconds

because I suggested

call a method to pull the list of notifications when required

But, I am OK with this:

I dont think it is worth to ignore returned info, and ask again

@chrisknoll chrisknoll added this to the Symposium 2018 Release milestone Oct 5, 2018
@chrisknoll
Copy link
Collaborator

Apologies, @pavgra , I did not recognize that consideration. However, I will say that I've seen tricky issues with if you have a poll on a setInterval, and then due to a user action you do a invoke-and-wait call to the same action that the setInterval does, you sometimes get this out of order refresh where the setInterval comes back with some slightly different data than your user-initiated call returns and it gets all flaky. So, my underlying concern was just have a single source of refresh (the polling) while being able to update the UI with some state that confirms to they user that we got the request and are working on it. Certainly doing @vantonov1 approach means there is no network latency involved.

But, I am OK with this:

Does that mean you are OK to approve the PR or did you want me to pull and review?

name: n.jobParameters.jobName,
status: ko.observable(n.status),
executionId: n.executionId,
viewed: ko.observable(false),
Copy link
Contributor

Choose a reason for hiding this comment

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

This causes notification icons to be highlighted on each page load

VAntonov and others added 6 commits October 16, 2018 11:48
@pavgra
Copy link
Contributor

pavgra commented Oct 17, 2018

@vantonov1 ,

  1. Generate cohort
  2. Wait until the cohort is generated and notifications are refreshed from server

image

@pavgra
Copy link
Contributor

pavgra commented Oct 17, 2018

@vantonov1 , there is following block of code in cohort-definition-manager.js:

// check if we can tell if the job to generate the reports is already running
					if (this.model.currentCohortDefinition()) {
					var listing = sharedState.jobListing;
						var tempJob = listing().find(this.isActiveJob)
					if (tempJob) {
						if (tempJob.status() == 'STARTED' || tempJob.status() == 'STARTING' || tempJob.status() == 'RUNNING') {
								this.currentJob(tempJob);
								this.generateReportsEnabled(false);
							return "generating_reports";
						}
					}
				}

As soon as we kick off 10 jobs after Cohort reporting (Heracles) it will stop working properly (the required job won't be in the shared state anymore -> need to query for the job status explicitly)

VAntonov and others added 9 commits October 19, 2018 12:16
…tifications_popup_fixing

# Conflicts:
#	js/components/cohortdefinitionviewer/main.js
#	js/components/negative-controls.js
#	js/components/user-bar.js
#	js/pages/cohort-definitions/cohort-definition-manager.js
#	js/pages/incidence-rates/ir-manager.js
#	js/services/JobDetailsService.js
@pavgra pavgra merged commit aeb7494 into master Oct 23, 2018
@chrisknoll chrisknoll deleted the ATLP-535/Notifications_popup_fixing branch November 8, 2018 04:28
@anthonysena anthonysena removed this from the After Symposium milestone Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants