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

Algorithmic transparency reports finder #2489

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/models/algorithmic_transparency_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class AlgorithmicTransparencyRecord < Document
validates :algorithmic_transparency_record_organisation, presence: true
validates :algorithmic_transparency_record_organisation_type, presence: true
validates :algorithmic_transparency_record_phase, presence: true
validates :algorithmic_transparency_record_date_published, presence: true
validates :algorithmic_transparency_record_atrs_version, presence: true

FORMAT_SPECIFIC_FIELDS = %i[
algorithmic_transparency_record_organisation
algorithmic_transparency_record_organisation_type
algorithmic_transparency_record_function
algorithmic_transparency_record_capability
algorithmic_transparency_record_task
algorithmic_transparency_record_phase
algorithmic_transparency_record_region
algorithmic_transparency_record_date_published
algorithmic_transparency_record_atrs_version
algorithmic_transparency_record_other_tags
].freeze

attr_accessor(*FORMAT_SPECIFIC_FIELDS)

def initialize(params = {})
super(params, FORMAT_SPECIFIC_FIELDS)
end

def self.title
"Algorithmic transparency record"
end

def primary_publishing_organisation
"c352c234-8083-47ec-8a4b-0edd45c31263"
end
end
102 changes: 102 additions & 0 deletions app/views/metadata_fields/_algorithmic_transparency_records.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_organisation, label: "Organisation" } do %>
<%= f.select :algorithmic_transparency_record_organisation,
f.object.facet_options(:algorithmic_transparency_record_organisation),
{
include_blank: true
},
{
class: 'select2 form-control',
multiple: false,
data: {
placeholder: 'Select organisation type'
}
}
%>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_organisation_type, label: "Organisation type" } do %>
<%= f.select :algorithmic_transparency_record_organisation_type,
f.object.facet_options(:algorithmic_transparency_record_organisation_type),
{},
{
class: 'select2 form-control',
multiple: true,
data: {
placeholder: 'Select organisation type'
}
}
%>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_function, label: "Function" } do %>
<%= f.select :algorithmic_transparency_record_function,
f.object.facet_options(:algorithmic_transparency_record_function),
{},
{
class: 'select2 form-control',
multiple: true,
data: {
placeholder: 'Select function'
}
}
%>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_capability, label: "Capability" } do %>
<%= f.select :algorithmic_transparency_record_capability,
f.object.facet_options(:algorithmic_transparency_record_capability),
{},
{
class: 'select2 form-control',
multiple: true,
data: {
placeholder: 'Select capability'
}
}
%>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_task, label: "Task" } do %>
<%= f.text_field :algorithmic_transparency_record_task, class: 'form-control' %>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_phase, label: "Phase" } do %>
<%= f.select :algorithmic_transparency_record_phase,
f.object.facet_options(:algorithmic_transparency_record_phase),
{
include_blank: true
},
{
class: 'select2 form-control',
multiple: false,
data: {
placeholder: 'Select phase'
}
}
%>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_region, label: "Region" } do %>
<%= f.select :algorithmic_transparency_record_region,
f.object.facet_options(:algorithmic_transparency_record_region),
{},
{
class: 'select2 form-control',
multiple: true,
data: {
placeholder: 'Select region'
}
}
%>
<% end %>

<%= render layout: "shared/date_fields", locals: { f: f, field: :algorithmic_transparency_record_date_published, format: :algorithmic_transparency_record, label: "Date published" } do %>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_atrs_version, label: "ATRS version" } do %>
<%= f.text_field :algorithmic_transparency_record_atrs_version, class: 'form-control' %>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :algorithmic_transparency_record_other_tags, label: "Other tags" } do %>
<%= f.text_field :algorithmic_transparency_record_other_tags, class: 'form-control' %>
<% end %>
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true

config.hosts << "specialist-publisher.dev.gov.uk"
end
23 changes: 11 additions & 12 deletions docs/creating-and-editing-specialist-document-types.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# Creating or editing specialist document types

To create or edit a new specialist document you will have to make changes to this
application, [govuk-content-schemas][govuk-content-schemas] and
[search-api][search-api]. You will not have to make any changes to frontend
application, [publishing-api][publishing-api] and [search-api][search-api]. You will not have to make any changes to frontend
applications.

[govuk-content-schemas]: https://github.com/alphagov/govuk-content-schemas
[publishing-api]: https://github.com/alphagov/publishing-api
[search-api]: https://github.com/alphagov/search-api

# __Creating__ a specialist document type

## 1. Add a schema to govuk-content-schemas

See example [PR for adding `product_safety_alert`](https://github.com/alphagov/govuk-content-schemas/pull/1077).
Note: this is a link to a PR in the now-archived content schemas repo. Content schemas have now been moved to publishing api.
Please update this document when an example for publishing api is available.
## 1. Add a schema to Publishing API
See [example PR here](https://github.com/alphagov/publishing-api/pull/2589/files)

1. Add the format to [this list](https://github.com/alphagov/publishing-api/blob/main/content_schemas/formats/specialist_document.jsonnet#L2:L33) and to [this list](https://github.com/alphagov/publishing-api/blob/main/content_schemas/allowed_document_types.yml)
2. Add any new field definitions to [this file](https://github.com/alphagov/publishing-api/blob/main/content_schemas/formats/shared/definitions/_specialist_document.jsonnet)
Expand Down Expand Up @@ -70,19 +66,22 @@ Finally, you'll need to add your custom fields to:

## 4. Configure the email sign up page

The email sign up page is rendered by [Finder Frontend](https://github.com/alphagov/finder-frontend) using the configuration in the new schema added to specialist publisher.
The email sign up page is rendered by [Finder Frontend](https://github.com/alphagov/finder-frontend) using the configuration in the new schema added to specialist publisher. The schema should specify `email_filter_by` and `email_filter_facets` (e.g. [cma-cases](https://github.com/alphagov/specialist-publisher/blob/ce68fdb008cab05225e0493e19decba5365e1e20/lib/documents/schemas/cma_cases.json#L29)).

If your email sign up page should have checkboxes (e.g. [cma-cases](https://www.gov.uk/cma-cases/email-signup)), you will need to edit email-alert-api by adding the new tags to [valid_tags.rb](https://github.com/alphagov/email-alert-api/blob/3e0018510ea85f5d561e2865ad149832b94688a1/lib/valid_tags.rb#L2).

## 5. Deploy and publish

To deploy:

1. Deploy Specialist Publisher and Search API (and govuk-content-schemas if you haven't already).
1. Deploy Publishing API (if you haven't already), Specialist Publisher and Search API.
- Ensure you deploy Publishing API first, to avoid schema validation errors.
- Also deploy Email Alert API if you have made changes to it.
2. [Reindex the govuk Elasticsearch index](https://docs.publishing.service.gov.uk/manual/reindex-elasticsearch.html#how-to-reindex-an-elasticsearch-index).
- This takes around 30-45 minutes on Production, or 3-4 hours on Integration.
- NB: reindexing shouldn't really be necessary; Elasticsearch will dynamically create the field mappings the first time a new document of this type is published. In other words, if you publish a new document type, the finder will work and it will return the relevant documents even without a reindex. However, the filters on the finder would not work, as this reindexing job also builds the filters for the finder, so we have to run the job.
3. Use the "Run rake task" Jenkins job to run `publishing_api:publish_finders` or `publishing_api:publish_finder[your_format_name_based_on_the_schema_file]` against the specialist publisher app on a backend machine.
- Alternatively, run `search:update_schema` for a shorter run. Make sure the this is run before any documents are published, otherwise a full reindex will be required.
- NB: reindexing shouldn't really be necessary; Elasticsearch will dynamically create the field mappings the first time a new document of this type is published. In other words, if you publish a new document type, the finder will work and it will return the relevant documents even without a reindex. However, **the filters on the finder would not work**, as this reindexing job also builds the filters for the finder, so we have to run the job.
3. Publish the finder; run the rake task `publishing_api:publish_finders` or `publishing_api:publish_finder[your_format_name_based_on_the_schema_file]` against the specialist publisher app (rake tasks [here](https://github.com/alphagov/specialist-publisher/blob/ce68fdb008cab05225e0493e19decba5365e1e20/lib/tasks/publishing_api.rake)).

## 6. Permissions

Expand Down
Loading
Loading