Skip to content
This repository has been archived by the owner on Jul 4, 2019. It is now read-only.

Moved HUI client over from kat-usage-reports #9

Merged
merged 9 commits into from
May 31, 2017
Merged

Moved HUI client over from kat-usage-reports #9

merged 9 commits into from
May 31, 2017

Conversation

dapenguin
Copy link
Contributor

No description provided.

// moments are mutable.
const adjustedStartDate = startDate.clone().startOf(aggregation === 'week' ? 'isoweek' : aggregation).subtract(1, aggregation);

const dateFormat = aggregation === 'week' ? '[wk]W/GGGG' : '[m]M/GGGG';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but, previously, the week start/end dates were created based on isoWeek (and year). Not sure if this results in the same dates.
https://github.com/Financial-Times/kat-usage-report/blob/master/server/lib/hui.js#L66

Copy link
Contributor Author

@dapenguin dapenguin May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, saw that as well. This code uses the ISO Week (the capital W in the dateFormat) and Year (GGGG), as per the MomentJS docs: https://momentjs.com/docs/#/displaying/, so it should be ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

lib/huiClient.js Outdated
@@ -0,0 +1,47 @@
const log = require('@financial-times/n-logger').default;

const huiBasePath = process.env.HUI_BASE_PATH;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe get these vars from the config.


log.debug({operation: 'getUsage', licenceId, aggregation, start, end, url});

return fetch(url, options)
Copy link
Contributor

@ciprianlujeru ciprianlujeru May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other client proxies use fetch-retry-or-die as fetch. This doesn't seem like it does.

lib/huiClient.js Outdated

const huiBasePath = process.env.HUI_BASE_PATH;
const licencePath = '/licences/';
const options = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to use fetch-retry-or-die (as mentioned below). You might want to extend config.fetchOptions (as all the other client proxies do - https://github.com/Financial-Times/kat-client-proxies/blob/master/lib/accessLicenceClient.js#L11)

lib/huiClient.js Outdated
log.debug({operation: 'getUsage', licenceId, aggregation, start, end, url});

return fetch(url, options)
.then((data) => data.json())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other proxies use helpers.parseJsonRes in order to parse the response.

@dapenguin dapenguin merged commit b4f5455 into master May 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants