Skip to content
This repository has been archived by the owner on Feb 13, 2018. It is now read-only.

Need exporter improvements #122

Merged
merged 24 commits into from Feb 1, 2017
Merged

Need exporter improvements #122

merged 24 commits into from Feb 1, 2017

Conversation

cbaines
Copy link
Contributor

@cbaines cbaines commented Jan 19, 2017

As the base_path's are dependent on the export order, and the default
order is descending, which would publish the newest content first
instead of last.
Fix off by one error, and add padding.
The data is numerical, so store it as a number.
This helps prevent the need exporter task timing out when running
locally. It's probably ineffective in production, due to request
duration limits elsewhere, but hopefully will not be necessary there.
This is consistent with Maslow, and looking at a few of the needs in
the Need API, should provide better URLs also.
end

def present_need_revision_group(need_revision_group, slug)
def present_need_revision_group(need_id, need_revision_group, slug)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this, could you get the need_id from the need_revision directly? In the console, NeedRevision.last.need_id gives me the need_id back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it this way because the need_id should be a constant over all of the revisions, and passing it in as a value makes the code read in the same way. I don't mind particularly though, I guess that getting it from the revisions is going to be fine in reality, and gets rid of an argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, I can see why having it as an argument highlights it doesn't change across revisions, happy for you to keep it like this.

@@ -41,6 +41,7 @@ def present_need_revision_group(need_revision_group, slug)

{
title: goal,
description: "As a #{role}, I need to #{goal}, so that #{benefit}",
Copy link
Contributor

Choose a reason for hiding this comment

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

How about rebasing to delete commit 24a6bf9 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the two commits related to the description now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and, yeah, that makes more sense.

p "#{index}/#{@needs.count}"
p "exported #{slug}"

padding = Math.log10(count).ceil
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what this padding does, could you explain in more detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its used in the string on the line below, maybe width would be a better name, as that is what its called in the format string documentation [1].

%#{padding}d will become something like %4d which will be substituted by format with the value given (index + 1), which will then become something like __14 (where the underscores are actually spaces), or 3000 with padding on the left of the string such that its 4 characters in width.

The desired width (or padding as its called above) is the number of characters required to display the largest possible index. The largest possible index is equal to the count, and to get the number of digits required to display it in base 10, you take the logarithm of that value in base 10, and round up.

All of this just gives you output formatted such that it moves around less, making it slightly easier to read.

1: https://ruby-doc.org/core-2.2.0/Kernel.html#method-i-format

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Most of the information comes across in the publication state in the
Publishing API.
The import endpoint has now changed to take a locale in the query
parameters, and not the history entries.
As this makes for better titles.
So that it can be used in the title.
As this information can be stored in the Unpublishing explanation.
For gds-api-adapters, as this includes the code to talk to the import endpoint
of the Publishing API.
@cbaines cbaines merged commit 1eda9cc into master Feb 1, 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