Skip to content

Commit

Permalink
WishlistSurvey: updates; new script for creating cat pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MusikAnimal committed Nov 16, 2020
1 parent cc50ad6 commit 92a1fbb
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions tasks/wishlist_survey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -666,24 +666,29 @@ def self.import_translations

# Write new translation, replacing the old year with new one.
@mb.edit(new_title,
content: translation.tr(last_year, this_year),
content: translation.sub(last_year, this_year),
summary: "Importing translations from last year's survey"
)
end
end

def self.get_old_participants
@mb = MusikBot::Session.new(inspect)
usernames = []

@survey_root = 'Community Wishlist Survey 2019'
proposals = get_proposals('Wikisource').merge(get_proposals('Wiktionary'))
usernames = get_editors_from_pages(proposals.keys) - [@mb.username]
@survey_root = 'Community Wishlist Survey 2020'
['Wikibooks', 'Wikinews', 'Wikiquote', 'Wikisource', 'Wikispecies', 'Wikiversity', 'Wikivoyage', 'Wiktionary'].each do |cat|
proposals = get_proposals(cat)
usernames += get_editors_from_pages(proposals.keys)
end

@survey_root = 'Community Wishlist Survey 2017'
proposals = get_proposals('Wikisource').merge(get_proposals('Wiktionary'))
usernames += get_editors_from_pages(proposals.keys) - [@mb.username]
@survey_root = 'Community Wishlist Survey 2019'
categories.each do |cat|
proposals = get_proposals(cat)
usernames += get_editors_from_pages(proposals.keys)
end

puts usernames.uniq.sort
puts (usernames - [@mb.username]).uniq.sort
.select { |u| !u.include?('(WMF)') }
.map { |u| "# {{target | user = #{u} | site = meta.wikimedia.org}}" }
end
Expand All @@ -692,15 +697,15 @@ def self.add_voting_sections
@mb = MusikBot::Session.new(inspect)

# Fetches from [[User:Community_Tech_bot/WishlistSurvey/config]].
@survey_root = @mb.config[:survey_root]
survey_root = @mb.config[:survey_root]

categories.each do |category|
proposals = get_proposals(category)

proposals.each do |proposal|
proposal_id = proposal[0]
proposal_title = proposal[1]
proposal_path = "#{@survey_root}/#{category}/#{proposal_title}"
proposal_path = "#{survey_root}/#{category}/#{proposal_title}"
content = @mb.get(proposal_path)

if !content.include?("=== Voting ===")
Expand All @@ -714,10 +719,34 @@ def self.add_voting_sections
end
end

def self.add_category_pages
@mb = MusikBot::Session.new(inspect)

survey_root = @mb.config[:survey_root]
categories = @mb.config[:categories]
year = (DateTime.now.year + 1).to_s

categories.each_with_index do |category, i|
prev_cat = categories[i - 1]
next_cat = categories[i + 1] || categories[0]
content = "{{:Community Wishlist Survey/Category header|#{prev_cat}|#{next_cat}}}\n"
@mb.edit("#{survey_root}/#{category}",
content: content,
summary: "Creating category pages for #{year} Wishlist Survey"
)
end

# Purge so links are up-to-date
categories.each do |category|
@mb.gateway.purge("#{survey_root}/#{category}")
end
end

end

WishlistSurvey.run
# WishlistSurvey.get_old_participants
# WishlistSurvey.sock_check
# WishlistSurvey.import_translations
# WishlistSurvey.add_voting_sections
# WishlistSurvey.add_category_pages
# WishlistSurvey.add_voting_sections

0 comments on commit 92a1fbb

Please sign in to comment.