micro-analytics-cli icon indicating copy to clipboard operation
micro-analytics-cli copied to clipboard

Adapter for mongodb

Open esakkiraj opened this issue 7 years ago • 9 comments

Hi

I am half way in writing a adapter for mongodb. Implementation is based on the given spec. Yet to published in npm.

Repo: https://github.com/esakkiraj/adapter-mongodb

esakkiraj avatar May 12 '17 02:05 esakkiraj

Cool, looks good 🎉

relekang avatar May 12 '17 05:05 relekang

That's awesome, can't wait to see this finished!

mxstbr avatar May 12 '17 05:05 mxstbr

Hi @relekang @mxstbr

Have almost done the implementation ( only two test's are failing, looking at it ). Meanwhile i thought there is mismatch in the specification and test for adapters for filter option.

Filter options before & after will be part of filter key in the options object. But in the adapter's test suite before and after key are passed in options object skipping the filter key.

Note: Currently i have managed to run the test by changing the implementation.

esakkiraj avatar May 14 '17 13:05 esakkiraj

@relekang any comments? I'm totally not in the context here, haven't looked at that API in a while.

mxstbr avatar May 14 '17 14:05 mxstbr

Looks like the docs and implementation is the same. The implementation sends this as options.

{
  pathname: pathname,
  before: parseInt(query.before, 10),
  after: parseInt(query.after, 10),
}

relekang avatar May 14 '17 17:05 relekang

Hi @relekang

As per the spec ( https://github.com/micro-analytics/micro-analytics-cli/blob/master/writing-adapters.md#options) filter is passed like this

await adapter.get('/hello', { filter: { after: 1200, before: 1234 }}) // -> { views: 20 }

but in the adapters-test suite the call is like

expect(await adapter.get('/a-key', { before: 1490623475640 })).toEqual({ views: [{ time: 1490623474639 }], });

I expected it to be

expect(await adapter.get('/a-key', { filter: { before: 1490623475640 } })).toEqual({ views: [{ time: 1490623474639 }], });

Don't know if i am missing something here.

esakkiraj avatar May 15 '17 02:05 esakkiraj

Yeah, that means that the spec differs from the implementation of micro-analytics-cli. If you follow the spec it will not work as expected, but if you follow the tests it will.

Not sure what we should do from here. If we should change the spec of change the implementation?

relekang avatar May 15 '17 05:05 relekang

I think let's change the Spec, since it's easier to do? I don't think there's big of a difference between those two APIs...

mxstbr avatar May 15 '17 06:05 mxstbr

The spec is updated now.

relekang avatar May 25 '17 09:05 relekang