Crunch-io / scrunch

Pythonic scripting library for cleaning data in Crunch
GNU Lesser General Public License v3.0
5 stars 7 forks source link

Do not read email from session #429

Closed jjdelc closed 2 years ago

xbito commented 2 years ago

Hi @jjdelc is root.session.user["body"]["email"] one or more http hits? If so, any chance to maybe cache it? Grab it on connect and put it somewhere that doesn't go to Crunch API each time needed?

jjdelc commented 2 years ago

@xbito thanks for this input, actually I think we can do better. We always do this to ensure that the current editor is the logged user. We fetch the email and then we discover the user URL from that email to perform the update.

I'll change it to obtain the URL first straight from session.views["user_url"] and make change_editor accept the URL and patch it directly. That way we actually reduce one request from the previous situation.

jjdelc commented 2 years ago

@xbito https://github.com/Crunch-io/scrunch/pull/429/commits/e24d8e7f4918a1f8ae2cdcc3321f04c1b15124a5 this commit makes all the calls to change_editor do one less request.