File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
data-migration/src/migrators Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,40 @@ class ChallengeMigrator extends BaseMigrator {
196196 }
197197 }
198198
199+ if ( record . tags !== undefined ) {
200+ if ( Array . isArray ( record . tags ) ) {
201+ const cleanedTags = [ ] ;
202+
203+ for ( const rawTag of record . tags ) {
204+ if ( rawTag === null || rawTag === undefined ) {
205+ continue ;
206+ }
207+
208+ if ( typeof rawTag !== 'string' ) {
209+ this . manager . logger . warn ( `Skipping invalid tag value for challenge ${ record [ this . getIdField ( ) ] } ; expected string, received ${ typeof rawTag } ` ) ;
210+ continue ;
211+ }
212+
213+ const trimmedTag = rawTag . trim ( ) ;
214+ if ( ! trimmedTag || trimmedTag . toLowerCase ( ) === 'null' ) {
215+ continue ;
216+ }
217+
218+ cleanedTags . push ( trimmedTag ) ;
219+ }
220+
221+ record . tags = cleanedTags ;
222+ } else if ( record . tags === null ) {
223+ record . tags = [ ] ;
224+ } else if ( typeof record . tags === 'string' ) {
225+ const trimmedTag = record . tags . trim ( ) ;
226+ record . tags = trimmedTag && trimmedTag . toLowerCase ( ) !== 'null' ? [ trimmedTag ] : [ ] ;
227+ } else {
228+ this . manager . logger . warn ( `Replacing unexpected tags value for challenge ${ record [ this . getIdField ( ) ] } ; defaulting to empty array` ) ;
229+ record . tags = [ ] ;
230+ }
231+ }
232+
199233 return record ;
200234 }
201235
You can’t perform that action at this time.
0 commit comments