View 2017-05-24-manuals-publisher-update.md

Done

  • Fixed bug caused by upgrade to Mongoid v4 in combination with legacy data
  • Refactored Section to significantly simplify it
  • Standardized interfaces to service classes
  • Simplified service classes by inlining lots of one-line methods
  • Use instances of Manual vs ManualRecord in a bunch of Rake tasks
  • Avoid saving model(s) if call to Publishing API fails
  • Simplified Manual#initialize & #update
  • Fix ActionController::UrlGenerationError exception occuring in production
View manual.rb
class Manual
include ActiveModel::Validations
validates :title, presence: true
validates :summary, presence: true
validates :body, safe_html: true
attr_reader(
:id,
:slug,
View 2017-05-17-manuals-publisher-update.md

Done

  • Finished extracting classes in app/exporters into PublishingAdapter
  • Upgraded gds-api-adapters to latest version
  • Upgraded to Mongoid v4 & Rails v4

Doing/planning

  • Refactoring PublishingAdapter to simplify & remove duplication
  • Finding remaining direct uses of Publishing API and changing them to use PublishingAdapter
View 2017-05-10-manuals-publisher-update.md

Done

  • More preparatory work for converting Section to Mongoid::Document
  • Collapsed formatter classes & RummagerIndexer into SearchIndexAdapter
  • Introduced PublishingAdapter to provide domain-level interface to Publishing API
  • Converted renderers into simpler and more Rails-like presenters
  • Preparatory work for upgrading to Mongoid v4 & Rails v4
  • Brought "lint" Rake task into line with "Lint Ruby" stage on CI
  • Inlined GovspeakHtmlConverter
View 2017-05-03-manuals-publisher-update.md

Done

  • Added a Rake task for the manual relocating functionality.
  • Renamed SectionEdition#section_id to #section_uuid in preparation for converting Section to Mongoid::Document.
  • Introduced SearchIndexAdapter to provide domain-level interface to Rummager API.
  • Upgraded non-locked Gems and their dependencies.

Doing

  • Converting Section to Mongoid::Document.
View parse_urls_from_sitemap.rb
require 'nokogiri'
response = get(sitemap_path)
doc = Nokogiri::XML(response.body)
namespace = 'http://www.sitemaps.org/schemas/sitemap/0.9'
locs = doc.xpath('//urlset:url//urlset:loc', 'urlset' => namespace)
urls = locs.map(&:text).map { |u| URI(u).path }.uniq
View ruby-dir-glob-returns-empty-array-when-too-many-open-files.txt
$ mkdir /tmp/ruby-dir-glob-returns-empty-array-when-too-many-open-files
$ cd /tmp/ruby-dir-glob-returns-empty-array-when-too-many-open-files
$ touch foo
$ ulimit -n 16
$ ruby -e "1.upto(16).map { |i| p [i, Dir.glob('*')]; File.new('foo') }"
[1, ["foo"]]
[2, ["foo"]]
[3, ["foo"]]
[4, ["foo"]]
[5, ["foo"]]
View remove_specialist_document_editions_with_non_manual_document_type_test.txt
vagrant@development:/var/govuk/manuals-publisher$ bin/document_types_report
## SpecialistDocumentEditions
* With non-manual document type: 23018
* With manual document type: 3688
## ManualRecord::Editions
* With mixed (manual vs non-manual) document types: []
* With only non-manual document types: []
View restore-govuk-content-development.sh
./replicate-data-local.sh -s -d backups/2017-02-23 -p -q -e -t -i "event_store transition backdrop support_contacts imminence content_store draft_content_store draft_router router authenticating_proxy admin test specialist_publisher_rebuild specialist_publisher_rebuild_standalone short_url_manager share_sale_publisher reviewomatic gov_delivery govuk_assets govuk_needs publisher panopticon maslow licence_finder govuk_delivery manuals_publisher"
View document_types_report_test.rb
def create_sd_edition_for(mr_edition, slug:, manual:)
id = BSON::ObjectId.new.to_s
type = manual ? 'manual' : 'aaib_report'
sd_edition = SpecialistDocumentEdition.create(document_id: id, slug: slug, document_type: type)
mr_edition.document_ids ||= []
mr_edition.document_ids << id
mr_edition.save!
sd_edition
end