Skip to content

Commit b3932e5

Browse files
committed
align matchmaking topic filters with canonical taxonomy
Replace the dynamic topic list with the agreed canonical options and map legacy stored topic labels so existing profiles still match the new filters. Made-with: Cursor
1 parent 3ab1803 commit b3932e5

2 files changed

Lines changed: 88 additions & 11 deletions

File tree

app/Filters/MatchmakingProfileFilters.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Filters;
44

5+
use App\MatchmakingProfile;
56
use Illuminate\Database\Eloquent\Builder;
67
use Illuminate\Http\Request;
78

@@ -160,7 +161,9 @@ protected function topics($values): Builder
160161
}
161162
return $this->builder->where(function ($q) use ($values) {
162163
foreach ($values as $value) {
163-
$q->orWhereJsonContains('digital_expertise_areas', $value);
164+
foreach (MatchmakingProfile::getTopicAliases($value) as $alias) {
165+
$q->orWhereJsonContains('digital_expertise_areas', $alias);
166+
}
164167
}
165168
});
166169
}

app/MatchmakingProfile.php

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ class MatchmakingProfile extends Model
7575
public const COLLABORATION_NO = 'No';
7676
public const COLLABORATION_MAYBE = 'Maybe, I would like more details';
7777

78+
public const TOPIC_CODING_PROGRAMMING = 'Coding & Programming';
79+
public const TOPIC_ICT_DIGITAL_SKILLS = 'ICT & Digital Skills';
80+
public const TOPIC_STEM_STEAM = 'STEM/STEAM education';
81+
public const TOPIC_DIGITAL_EDTECH = 'Digital Education & EdTech';
82+
public const TOPIC_CYBERSECURITY = 'Cybersecurity';
83+
public const TOPIC_MEDIA_LITERACY = 'Media Literacy';
84+
public const TOPIC_AI_ML = 'AI & Machine Learning';
85+
public const TOPIC_AI_LITERACY = 'AI Literacy';
86+
public const TOPIC_GRAPHIC_DESIGN = 'Graphic Design';
87+
public const TOPIC_MARKETING_SOCIAL = 'Marketing & Social Media';
88+
public const TOPIC_OTHER = 'Other';
89+
7890
// Static helpers for validation / form use
7991
public static function getValidTypes(): array
8092
{
@@ -118,16 +130,78 @@ public static function getValidOrganizationTypeOptions(): array
118130

119131
public static function getUniqueDigitalExpertiseAreas(): array
120132
{
121-
return MatchmakingProfile::query()
122-
->pluck('digital_expertise_areas')
123-
->filter()
124-
->flatMap(function ($item) {
125-
return is_array($item) ? $item : [];
126-
})
127-
->unique()
128-
->sort()
129-
->values()
130-
->all();
133+
return self::getTopicOptions();
134+
}
135+
136+
public static function getTopicOptions(): array
137+
{
138+
return [
139+
self::TOPIC_CODING_PROGRAMMING,
140+
self::TOPIC_ICT_DIGITAL_SKILLS,
141+
self::TOPIC_STEM_STEAM,
142+
self::TOPIC_DIGITAL_EDTECH,
143+
self::TOPIC_CYBERSECURITY,
144+
self::TOPIC_MEDIA_LITERACY,
145+
self::TOPIC_AI_ML,
146+
self::TOPIC_AI_LITERACY,
147+
self::TOPIC_GRAPHIC_DESIGN,
148+
self::TOPIC_MARKETING_SOCIAL,
149+
self::TOPIC_OTHER,
150+
];
151+
}
152+
153+
/**
154+
* Map canonical topic labels to legacy values already stored in DB.
155+
*/
156+
public static function getTopicAliases(string $topic): array
157+
{
158+
$aliases = [
159+
self::TOPIC_CODING_PROGRAMMING => [
160+
self::TOPIC_CODING_PROGRAMMING,
161+
'Coding and programming',
162+
],
163+
self::TOPIC_ICT_DIGITAL_SKILLS => [
164+
self::TOPIC_ICT_DIGITAL_SKILLS,
165+
'Digital skills',
166+
'ICT',
167+
],
168+
self::TOPIC_STEM_STEAM => [
169+
self::TOPIC_STEM_STEAM,
170+
],
171+
self::TOPIC_DIGITAL_EDTECH => [
172+
self::TOPIC_DIGITAL_EDTECH,
173+
'Digital Education and EdTech',
174+
],
175+
self::TOPIC_CYBERSECURITY => [
176+
self::TOPIC_CYBERSECURITY,
177+
'Cyber security',
178+
],
179+
self::TOPIC_MEDIA_LITERACY => [
180+
self::TOPIC_MEDIA_LITERACY,
181+
'Media literacy',
182+
],
183+
self::TOPIC_AI_ML => [
184+
self::TOPIC_AI_ML,
185+
'Artificial Intelligence & Machine Learning',
186+
'Artificial Intelligence and Machine Learning',
187+
],
188+
self::TOPIC_AI_LITERACY => [
189+
self::TOPIC_AI_LITERACY,
190+
'AI literacy',
191+
],
192+
self::TOPIC_GRAPHIC_DESIGN => [
193+
self::TOPIC_GRAPHIC_DESIGN,
194+
],
195+
self::TOPIC_MARKETING_SOCIAL => [
196+
self::TOPIC_MARKETING_SOCIAL,
197+
'Marketing and Social Media',
198+
],
199+
self::TOPIC_OTHER => [
200+
self::TOPIC_OTHER,
201+
],
202+
];
203+
204+
return $aliases[$topic] ?? [$topic];
131205
}
132206

133207
/**

0 commit comments

Comments
 (0)