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

Retrieving events #61

Closed
xtr3me opened this issue Apr 5, 2018 · 11 comments
Closed

Retrieving events #61

xtr3me opened this issue Apr 5, 2018 · 11 comments

Comments

@xtr3me
Copy link

xtr3me commented Apr 5, 2018

When trying to retrieve all events from a project via the new Event service i came across the following difference between this package and the gitlab api:

https://docs.gitlab.com/ee/api/events.html#list-a-project-39-s-visible-events
The API states that: action and targetType are optional yet this package makes them mandatory as seen in: https://github.com/jdalrymple/node-gitlab-api/blob/4e78749edcd6022736cb8c0471df008de2fc3d19/src/services/Events.js#L27

This prevents me from using the Events service as i cant retrieve all the events.

(ps. i'm only interested in pushed events on the project, but i get an empty response when using:
{ action: 'pushed', targetType: 'project' }, that's how i found the difference between the API and the Service)
(ps2. how can i see the complete response and not only the parsed response for debugging purposes)

@jdalrymple
Copy link
Owner

Must of missed that! Hmm right now the full responses are hidden for clarity, but maybe adding a debug option to expose those would be helpful

@xtr3me
Copy link
Author

xtr3me commented Apr 5, 2018

I can make a PR, do you want to remove the validateEventOptions all together or do you have a different idea about that?

@jdalrymple
Copy link
Owner

jdalrymple commented Apr 5, 2018

That would be amazing if you dont mind! I think validateEventOptions should still be used, but only validate if the options exist. If they dont exist it should assume things are valid. Not sure what the best way to go about that would be. Maybe

function validateEventOptions(action, target) {
  if (action && !ACTION_TYPES.includes(action)) {
    throw new Error(`This action is not supported. Pleased use one of following options: ${ACTION_TYPES}`);
  }

  if (target && !TARGET_TYPES.includes(target)) {
    throw new Error(`This target is not supported. Pleased use one of following options: ${TARGET_TYPES}`);
  }
}

@jdalrymple
Copy link
Owner

Fixing it now :)

@jdalrymple
Copy link
Owner

Should be fixed now!

@hsablonniere
Copy link

Hey @jdalrymple ;-)

In 4.2.2, the action and target are still required:
https://github.com/jdalrymple/node-gitlab/blob/4.2.2/src/services/Events.ts#L32-L36

I would like to list all events with after and before but without any types...

@jdalrymple jdalrymple reopened this Nov 26, 2018
@jdalrymple
Copy link
Owner

Oh man, sorry :( Ill look soon

@jdalrymple
Copy link
Owner

Just released to npm and the next build!

jdalrymple pushed a commit that referenced this issue Nov 26, 2018
## [4.2.3](4.2.2...4.2.3) (2018-11-26)

### Bug Fixes

* Filtering all events shouldnt require an action or a target [#61](#61) ([cda23b8](cda23b8))
@hsablonniere
Copy link

@jdalrymple Thanks very much for doing it so fast. In the hurry you made a small mistake.

You wrote:

if (action || !(action in ACTION_TYPES)) {
/// ...
if (target || !(target in TARGET_TYPES)) {

instead of:

if (action && !(action in ACTION_TYPES)) {
/// ...
if (target && !(target in TARGET_TYPES)) {

@jdalrymple
Copy link
Owner

Oops! One moment!

@hsablonniere
Copy link

@jdalrymple It works!! 🎉 Thanks very much!

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

3 participants