-
Notifications
You must be signed in to change notification settings - Fork 386
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
CLDR-17248 Measure vote timing; log times to console; refactor to use fetch #3392
Conversation
… fetch -Make cldrVote.CLDR_VOTE_DEBUG true; log times to console -Refactor to use modern cldrAjax.doFetch instead of legacy cldrAjax.sendXhr -Reduce very long functions and nested subroutines -Sanitize error message with new method makeSafe to avoid security warning -Comments
Hooray! The files in the branch are the same across the force-push. 😃 ~ Your Friendly Jira-GitHub PR Checker Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Called from cldrTable.addValueVote (for new value submission) | ||
* as well as locally in cldrVote (vote for existing value or abstain) | ||
*/ | ||
function handleWiredClick(tr, theRow, vHash, newValue, button) { | ||
async function handleWiredClick(tr, theRow, vHash, newValue, button) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
tr.innerHTML = | ||
"<td colspan='4'>" + | ||
cldrStatus.stopIcon() + | ||
" Could not check value. Try reloading the page.<br>" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a cldrNotify instead? in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we need to say something here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tried using cldrNotify and got stuck on some problems with cleaning up the input window, row background color, etc., so I decided not to change too much with this PR
I did some testing by temporarily changing the back end to return Auth.noSessionResponse() or Response.Status.NOT_FOUND, as well as inputting values that triggered errors
The tr_err class shows the messages with black text on a deep red background, not ideal, but one has to pick one's battles :-)
@@ -553,18 +558,24 @@ function oneLessPendingVote() { | |||
function isBusy() { | |||
if (pendingVoteCount > 0) { | |||
if (CLDR_VOTE_DEBUG) { | |||
console.log("cldrVote busy: pendingVoteCount = " + pendingVoteCount); | |||
console.log( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea for future ; this would be better as:
const cldrVote = cldrDebug.getDebugLog(CLDR_VOTE_DEBUG, "cldrVote");
…
cldrVote.log(()=>`cldrVote busy: pendingVoteCount = ${pendingVoteCount} time=${Date.now())`);
where cldrVote
is an object that handles logging. if logging is off, then the log function ()=> isn't called .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that sounds good!
} | ||
return true; | ||
} | ||
if (CLDR_VOTE_DEBUG) { | ||
console.log("cldrVote not busy"); | ||
console.log("cldrVote not busy; time = " + time); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a logging framework ( https://getpino.io/#/ is one i've used / contributed to though not in browser , or something homegrown) could collect timings automatically
-Make cldrVote.CLDR_VOTE_DEBUG true; log times to console
-Refactor to use modern cldrAjax.doFetch instead of legacy cldrAjax.sendXhr
-Reduce very long functions and nested subroutines
-Sanitize error message with new method makeSafe to avoid security warning
-Comments
CLDR-17248
ALLOW_MANY_COMMITS=true