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

CLDR-17248 Measure vote timing; log times to console; refactor to use fetch #3392

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

btangmu
Copy link
Member

@btangmu btangmu commented Nov 22, 2023

-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

  • This PR completes the ticket.

ALLOW_MANY_COMMITS=true

@btangmu btangmu self-assigned this Nov 22, 2023
… 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
@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@btangmu btangmu requested a review from srl295 November 22, 2023 16:08
Copy link
Member

@srl295 srl295 left a 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) {
Copy link
Member

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>" +
Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

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(
Copy link
Member

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 .

Copy link
Member Author

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);
Copy link
Member

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

@btangmu btangmu merged commit 94e0382 into unicode-org:main Nov 23, 2023
8 checks passed
@btangmu btangmu deleted the t17248_c branch November 23, 2023 17:02
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.

2 participants