"Fossies" - the Fresh Open Source Software Archive

Member "discourse-2.8.3/plugins/discourse-narrative-bot/db/fixtures/002_badges.rb" (14 Apr 2022, 1184 Bytes) of package /linux/www/discourse-2.8.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # frozen_string_literal: true
    2 
    3 Badge
    4   .where(name: 'Complete New User Track')
    5   .update_all(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME)
    6 
    7 Badge
    8   .where(name: 'Complete Discobot Advanced User Track')
    9   .update_all(name: DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME)
   10 
   11 new_user_narrative_badge = Badge.find_by(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME)
   12 
   13 unless new_user_narrative_badge
   14   new_user_narrative_badge = Badge.create!(
   15     name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME,
   16     badge_type_id: 3
   17   )
   18 end
   19 
   20 advanced_user_narrative_badge = Badge.find_by(name: DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME)
   21 
   22 unless advanced_user_narrative_badge
   23   advanced_user_narrative_badge = Badge.create!(
   24     name: DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME,
   25     badge_type_id: 2
   26   )
   27 end
   28 
   29 badge_grouping = BadgeGrouping.find(1)
   30 
   31 [
   32   [new_user_narrative_badge, I18n.t('badges.certified.description')],
   33   [advanced_user_narrative_badge, I18n.t('badges.licensed.description')]
   34 ].each do |badge, description|
   35 
   36   badge.update!(
   37     badge_grouping: badge_grouping,
   38     description: description,
   39     system: true
   40   )
   41 end