Skip to content

Commit

Permalink
Add challenge_area to people.schema.json
Browse files Browse the repository at this point in the history
  • Loading branch information
oshadura committed Nov 29, 2024
1 parent c3dad38 commit d6bf17a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
39 changes: 39 additions & 0 deletions _scripts/challenge_area.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

require 'yaml'
require 'pathname'
require 'set'

def ensure_array(arr)
return [] if arr.nil?

arr.is_a?(Array) ? arr : [arr]
end

project_files = Pathname.glob('pages/projects/*.md')
counter = {}
project_files.each do |fn|
proj = YAML.load_file fn

fa = ensure_array proj['challenge-area']
team = ensure_array proj['team']
team.reject! { _1.include?(' ') }&.reject! { _1.include?('@') }

fa.each { |a| team.each { |t| counter[t] = (counter[t] || Set.new) << a } }
end

people_files = Pathname.glob('_data/people/*.yml')
people_files.each do |fn|
info = YAML.load_file fn

user_fa = info['presentations']&.flat_map { ensure_array(_1['challenge-area']) }&.to_set&.delete('core')
proj_fa = counter[info['shortname']]&.delete('core')
puts "#{info['name']}: #{user_fa.to_a} | #{proj_fa.to_a}"
all_fa = (user_fa || Set.new) | (proj_fa || Set.new)
info['challenge-area'] = all_fa.to_a unless all_fa.empty?

sorted = info.sort_by { _1 }.to_h
sorted['presentations'] = sorted.delete 'presentations'

fn.write(sorted.to_yaml.lines[1..].join)
end
4 changes: 4 additions & 0 deletions _scripts/people.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"focus_area": {
"enum": ["as", "ia", "ssc", "doma", "ssl", "osglhc", "core"]
},
"challenge_area": {
"enum": ["analysis-grand-challenge"]
},
"focus_areas": {
"oneOf": [
{ "type": "null" },
Expand All @@ -62,6 +65,7 @@
"meeting": { "$ref": "#/definitions/empty_string" },
"meetingurl": { "$ref": "#/definitions/empty_string" },
"focus-area": { "$ref": "#/definitions/focus_areas" },
"challenge-area": { "$ref": "#/definitions/challenge_area" },
"project": { "$ref": "#/definitions/string_or_array" },
"location": { "$ref": "#/definitions/empty_string" },
"comment": { "$ref": "#/definitions/empty_string" },
Expand Down

0 comments on commit d6bf17a

Please sign in to comment.