Skip to content

Commit

Permalink
Merge pull request #455 from UCF/hf-degree-import-change
Browse files Browse the repository at this point in the history
Updated degree import to work with new search service schema
jmbarne3 authored Jan 24, 2024
2 parents 39b75d7 + feee0e0 commit 97a0ccc
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions includes/degree-import-functions.php
Original file line number Diff line number Diff line change
@@ -147,8 +147,11 @@ function mainsite_degree_format_post_data( $meta, $program ) {
* @return array
*/
function mainsite_degree_get_post_terms( $terms, $program ) {
$careers = main_site_get_remote_response_json( "{$program->careers}ranked/", array() );
$terms['career_paths'] = mainsite_filter_career_paths( $careers );
$careers = main_site_get_remote_response_json( "{$program->careers}", array() );

if ( $careers !== null ) {
$terms['career_paths'] = $careers;
}

$area_of_interest = $program->subarea_of_interest;

@@ -165,32 +168,6 @@ function mainsite_degree_get_post_terms( $terms, $program ) {

add_filter( 'ucf_degree_get_post_terms', 'mainsite_degree_get_post_terms', 10, 2 );

/**
* Filters the careers from the ranked endpoint
* by weight and limiting to the max number of
* career paths.
*
* @author Jim Barnes
* @since 3.4.0
* @param array $careers The array of career objects from the search service
* @return array[string] The array of career names
*/
function mainsite_filter_career_paths( $careers ) {
$threshold = get_theme_mod( 'degrees_careers_weight_threshold' );
$limit = get_theme_mod( 'degrees_careers_per_program_limit' );
$retval = array();

foreach ( $careers as $i => $career ) {
if ( $career->weight < $threshold || $i === $limit - 1 ) {
break;
}

$retval[] = $career->job;
}

return $retval;
}


/**
* Handles writing the excerpt into the post_excerpt

0 comments on commit 97a0ccc

Please sign in to comment.