-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creation of `expertise` model and `expertisable` relationship - expertises can now be added to the author profiles. Expertise used are from the sciences.gc.ca and RESE lists. Keeping only unique values and discarding the taxonomy of the science profiles which introduced too much redundancy, contradictions, as well as a few typos.
- Loading branch information
1 parent
6e7cd2e
commit 00790e8
Showing
62 changed files
with
14,477 additions
and
874 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
|
||
namespace App\Actions\Expertise; | ||
|
||
use App\Models\Expertise; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class SyncExpertiseWithScience | ||
{ | ||
public static function handle(): bool | ||
{ | ||
$url = 'https://profils-profiles.science.gc.ca/api/views/admin_taxonomy_term?display_id=services_1'; | ||
|
||
$response = Http::get($url); | ||
if (! $response->ok()) { | ||
return false; | ||
} | ||
|
||
$expertises = collect($response->json()); | ||
|
||
// lower case array of keywords to remove in english | ||
$termsToRemove = [ | ||
'bio-informatics', | ||
'biological', | ||
]; | ||
|
||
// Taken from RESE guidance - retreived on: 2023-10-27 | ||
$reseExperties = [ | ||
['Aquaculture', "L'aquaculture"], | ||
['Finfish', 'Poisson à nageoires'], | ||
['Pathogens', 'Les agents pathogènes'], | ||
['Shellfish', 'Mollusques et crustacés'], | ||
['Wild / Cultured interactions', 'Interactions entre les espèces sauvages et les espèces cultivées'], | ||
['Biology and Ecology', 'Biologie et écologie'], | ||
['Benthic Ecology', 'Écologie benthique'], | ||
['Fish Biology', 'Biologie des poissons'], | ||
['Invertebrate Biology', 'Biologie des invertébrés'], | ||
['Harmful Algal Blooms', 'Efflorescences algales nuisibles'], | ||
['Aquatic Invasive Species', 'Espèces aquatiques envahissantes'], | ||
['Marine Mammal Biology', 'Biologie des mammifères marins'], | ||
['Freshwater Ecology', 'Écologie des eaux douces'], | ||
['Ecosystems Features', 'Caractéristiques des écosystèmes'], | ||
['Marine Protected Areas', 'Zones marines protégées'], | ||
['Cold-water corals and sponges', "Coraux et éponges d'eau froide"], | ||
['Hydrothermal vents', 'Foyers hydrothermaux'], | ||
['Seamounts', 'Monts sous-marins'], | ||
['Eelgrass', 'La zostère'], | ||
['Fisheries and Stock Groups', 'Pêcheries et groupes de stocks'], | ||
['Management Strategies', 'Stratégies de gestion'], | ||
['Stock Assessments', 'Évaluation des stocks'], | ||
['Crustaceans', 'Crustacés'], | ||
['Groundfish', 'Poissons de fond'], | ||
['Large pelagics ', 'Grands pélagiques '], | ||
['Other Stock Groups', "Autres groupes d'actions"], | ||
['Salmonids', 'Salmonidés'], | ||
['Small pelagics', 'Petits pélagiques'], | ||
['Survey design', "Conception de l'enquête"], | ||
['Marine Mammals', 'Mammifères marins'], | ||
['Mollusks', 'Mollusques'], | ||
['Genetics', 'Génétique'], | ||
['Designatable Units', 'Unités désignables'], | ||
['Genomics', 'Génomique'], | ||
['Introgression', 'Introgression'], | ||
['Stock Structure', 'Structure du stock'], | ||
['Habitat', 'Habitat'], | ||
['Estuarine', 'Estuaire'], | ||
['Freshwater', 'Eau douce'], | ||
['Marine', 'Marine'], | ||
['Modeling, Statistics and Bioinformatics', 'Modélisation, statistiques et bioinformatique'], | ||
['Bioinformatics', 'Bioinformatique'], | ||
['Current modeling', 'Modélisation des courants'], | ||
['Fisheries modeling', 'Modélisation de la pêche'], | ||
['Oceans modeling', 'Modélisation des océans'], | ||
['Quantitative modeling', 'Modélisation quantitative'], | ||
['Spatial modeling', 'Modélisation spatiale'], | ||
['Spatiotemporal statistics', 'Statistiques spatio-temporelles'], | ||
['Oceanography', 'Océanographie'], | ||
['Biological oceanography', 'Océanographie biologique'], | ||
['Ocean chemistry', 'Chimie des océans'], | ||
['Ocean monitoring', 'Surveillance des océans'], | ||
['Physical chemistry', 'Chimie physique'], | ||
]; | ||
|
||
// add rese experties to the Science expertise list | ||
foreach ($reseExperties as $expertise) { | ||
$expertises->push([ | ||
'name_en' => $expertise[0], | ||
'name_fr' => $expertise[1], | ||
]); | ||
} | ||
|
||
$unique = $expertises | ||
->unique(function ($expertise) { | ||
return strtolower($expertise['name_en']); | ||
}) | ||
->unique(function ($expertise) { | ||
return strtolower($expertise['name_fr']); | ||
}) | ||
->filter(function ($expertise) use ($termsToRemove) { | ||
$a = strtolower($expertise['name_en']); | ||
|
||
return ! in_array($a, $termsToRemove); | ||
}); | ||
|
||
foreach ($unique as $expertise) { | ||
Expertise::updateOrCreate( | ||
[ | ||
'name_en' => html_entity_decode($expertise['name_en']), | ||
], | ||
[ | ||
'name_fr' => html_entity_decode($expertise['name_fr']), | ||
] | ||
); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class SyncExpertises extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'osp:sync-expertises'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Sync the local database with the expertise taxonomy from the profiles registry at profils-profiles.science.gc.ca'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$this->info('Syncing expertises...'); | ||
|
||
$result = \App\Actions\Expertise\SyncExpertiseWithScience::handle(); | ||
|
||
if (! $result) { | ||
$this->error('Failed to sync expertises!'); | ||
|
||
return; | ||
} | ||
|
||
$this->info('Expertises synced!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.