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

Voctoweb: Use guid instead of local event id? #81

Open
saerdnaer opened this issue Dec 23, 2019 · 2 comments
Open

Voctoweb: Use guid instead of local event id? #81

saerdnaer opened this issue Dec 23, 2019 · 2 comments

Comments

@saerdnaer
Copy link
Member

Voctoweb's private API also supports updates via GUID [1], so we could replace the current handling via following:

  • lookup if event guid already exits in voctoweb viahead request
  • if yes: patch
  • if not: post

of course there would be other ways to reduce the actual requests for the general case, e.g. :

  • first try to patch the event, if that fails post it
  • use the event id in the ticket only as a flag, if the event was created or not
  • ...

current implementations:

# call voctoweb api
try:
# TODO make ssl verify a config option
# r = requests.post(url, headers=headers, data=json.dumps(payload), verify=False)
if self.t.voctoweb_event_id:
r = requests.patch(url, headers=headers, data=json.dumps(payload))
else:
r = requests.post(url, headers=headers, data=json.dumps(payload))

if self.t.voctoweb_event_id:
# check the public API if voctoweb knows this event before patching it
try:
r = requests.get(url[:-3] + "public/events/" + self.t.voctoweb_event_id)
except requests.exceptions.BaseHTTPError as e_:
raise VoctowebException("error while checking event id with public API") from e_
if r.status_code == 200:
try:
r = requests.patch(url, headers=headers, data=json.dumps(payload))
except requests.exceptions.BaseHTTPError as e_:
raise VoctowebException("error while patching event") from e_
else:
raise VoctowebException("Event id from ticket is not known to voctoweb. Something is out of sync")
try:
r = requests.post(url, headers=headers, data=json.dumps(payload))
except requests.exceptions.RetryError as e:
raise VoctowebException("Error during creation of event: " + str(e)) from e
return r

[1] https://github.com/voc/voctoweb/blob/master/app/controllers/api/events_controller.rb#L76-L83

@saerdnaer saerdnaer mentioned this issue Dec 23, 2019
Closed
@saerdnaer
Copy link
Member Author

saerdnaer commented Dec 23, 2019

Thinking about it,

first try to patch the event, if that fails with 404 post it

is probably the best solution...

@derpeter
Copy link
Contributor

I'm not sure i got what is the purpose of this issue.

  • Is this about updating an already existing event or the normal publishing ?
  • What is the advantage of using the GUID over the ID. We stayed with the ID as its much easier for humans to read and debug.
  • Why not ask the API if the guid exist instead of trying to handle an error
  • We currently have a similar behavior where we handle also handle errors instead of querying and i want to get rid of that for a long time.

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

No branches or pull requests

2 participants