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

Add course summary card to the new results page #4825

Conversation

tomas-stefano
Copy link
Contributor

@tomas-stefano tomas-stefano commented Jan 15, 2025

Context

This PR adds all the course summary content into the search result.

The goal was:

  • Simplify the views and the component and the locales in comparison from the old search result (you can compare with SearchResultComponent if you want)

If you wanna see the details of each field please read the commit message.

Caveats

  • There are N+1 queries on this PR - this will be addressed in future PR.

@tomas-stefano tomas-stefano added the deploy A Review App will be created for PRs with this label label Jan 15, 2025
- **Location field**: Provides a label describing the course's placement location information.
  - Potential values:
    - "Placement schools" for Fee
    - "Employing school" (for one school) / "Employing schools" (for multiple schools) for Salary and Apprenticeship
  - Dependencies: `course.funding`, `available_placements_count`

- **Location Value**: Displays detailed placement location information and proximity to the user's search location.
  - Potential values:
    - "Not listed yet"
    - "Nearest of X potential [school_term] school(s)"
    - "X potential [school_term] school(s)"
    - "X miles from [location]"
  - Dependencies:
    - `available_placements_count`
    - `@search_params[:location]`
    - `course.minimum_distance_to_search_location`
    - `school_term` (dynamic based on `course.funding`)

- **Fee field name**: A label indicating the fees associated with the course.
  - Potential values: "Fee or salary"

- **Fee Value**: Provides details on the fees for UK and international students or mentions that the course is salaried.
  - Potential values:
    - "Salary"
    - "Salary (apprenticeship)"
    - "Fees for UK students": "%{value} for UK citizens"
    - "Fees for international students": "%{value} for Non-UK citizens"
    - Bursaries and Scholarships hint:
      - "Bursaries of %{bursary_amount} are available"
      - "Scholarships of %{scholarship_amount} are available"
      - "Scholarships of %{scholarship_amount} or bursaries of %{bursary_amount} are available"
  - Rules for displaying bursaries:
    - Hidden when the financial incentives feature flag is off.
    - Displays based on the course’s main subject and financial incentive.
    - When "visa sponsorship" filter is applied, affects bursary/scholarship hint display (show when Physics and languages only).
  - Dependencies:
    - `course.funding`, `fee_uk`, `fee_international`, `main subject -> financial_incentive`

- **Course Length field**: A label indicating the duration of the course.
  - Potential values: "Course Length"

- **Course Length Value**: Displays the duration of the course along with the study mode.
  - Potential values: "1 year - full-time," "2 years - part-time"
  - Dependencies: `course.enrichment_attribute(:course_length)`, `course.study_mode`

- **Age Group**: A label describing the age group the course is aimed at.
  - Potential values: "Age Group"

- **Age Group Value**: Indicates the level of the course and the age range it covers.
  - Potential values: "Primary - 5 to 11," "Secondary - 11 to 16"
  - Dependencies: `course.level`, `course.age_range_in_years`

- **Qualification**: A label describing the type of qualification awarded by the course.
  - Potential values: "Qualification awarded"

- **Qualification Value**: Specifies the qualification type.
  - Potential values:
    - "QTS" (QTS only)
    - "QTS with PGCE"
    - "QTS with PGDE"
    - "PGCE without QTS"
    - "PGDE without QTS"
    - "Undergraduate degree with QTS"
  - Notes for Abbreviations: Displays terms (e.g., QTS, PGCE) directly in the browser.
  - Dependencies: `course.qualification`

- **Degree Requirements**: A label describing the degree requirements for the course.
  - Potential values:
    - Postgraduate:
      - "2:1 bachelor’s degree"
      - "2:2 bachelor’s degree"
      - "Bachelor’s degree"
    - Undergraduate: "No degree required"
  - Dependencies: `course.degree_type`, `course.degree_grade`

- **Visa Sponsorship**: A label indicating whether the course supports visa sponsorship.
  - Potential values:
    - "Visa Sponsorship"

- **Visa Sponsorship Value**: Indicates visa sponsorship eligibility for international students.
  - Potential values:
    - "Visas cannot be sponsored"
    - "Student visas can be sponsored"
    - "Skilled Worker visas can be sponsored"
  - Dependencies: `course.visa_sponsorship`, `course.funding`
@tomas-stefano tomas-stefano force-pushed the td/313-improve-results-update-results-and-course-summary-content branch from 9e44c92 to c4ceb6e Compare January 16, 2025 11:36
t(
'.location_value.distance',
school_term:,
distance: content_tag(:span, pluralize(course.minimum_distance_to_search_location, 'mile'), class: 'govuk-!-font-weight-bold'),
Copy link
Contributor Author

@tomas-stefano tomas-stefano Jan 16, 2025

Choose a reason for hiding this comment

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

the minimum_distance_to_search_location still doesn't exist. The idea is to return into the SELECT statement because we shouldn't be looping through all the placements in Ruby to calculate the minimum distance from the user searched location.

This will be done when the location search is implemented.

AND site.latitude IS NULL
AND site.longitude IS NULL"
)
end
Copy link
Contributor Author

@tomas-stefano tomas-stefano Jan 16, 2025

Choose a reason for hiding this comment

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

I moved the Ruby loop and add a SQL for it. Although I didn't add any spec (because this will be removed).

The idea is to remove this code and return also in the SELECT statement the available placements count.

First I isolated here, so I can remove before the pre-filter work is finished.

This will be done in a separate PR.


def main_subject
@main_subject ||= Subject.find_by(id: course.master_subject_id)
end
Copy link
Contributor Author

@tomas-stefano tomas-stefano Jan 16, 2025

Choose a reason for hiding this comment

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

We need to create the "main subject" concept into the app.

For now I added here.

I will create a trello card and make sure it is finished before the prefilter work is delivered.

This also will be done in a separate card.


def financial_incentive
@financial_incentive ||= main_subject&.financial_incentive
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One more query to the DB for each search result.

Will check performance in a separate PR.

@tomas-stefano tomas-stefano marked this pull request as ready for review January 16, 2025 11:45
@tomas-stefano tomas-stefano requested a review from a team as a code owner January 16, 2025 11:45
@tomas-stefano
Copy link
Contributor Author

@tomas-stefano tomas-stefano changed the title [DO NOT REVIEW YET] - Add course summary card to the new results page Add course summary card to the new results page Jan 16, 2025
Copy link
Contributor

@inulty-dfe inulty-dfe left a comment

Choose a reason for hiding this comment

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

Looks good.

Couple of suggestions

app/components/courses/summary_card_component.rb Outdated Show resolved Hide resolved
@@ -892,6 +892,44 @@ def name_and_code
"#{name} (#{course_code})"
end

def available_placements
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be better living in a module?

AvailablePlacements.new(course:).call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a good idea, but this code will be removed because this should be in the db SELECT list on the courses query, so I am reluctantly to move to a class now.

Only passes the parameters it uses not the whole search params

This components only uses location and visa sponsorship
It should help with the template visualisation too.
Now we now that all fields have a key, a value, and a possible hint.
@tomas-stefano tomas-stefano merged commit 4282c6d into main Jan 17, 2025
19 checks passed
@tomas-stefano tomas-stefano deleted the td/313-improve-results-update-results-and-course-summary-content branch January 17, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy A Review App will be created for PRs with this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants