"Fossies" - the Fresh Open Source Software Archive

Member "discourse-3.1.1/plugins/discourse-narrative-bot/db/fixtures/002_badges.rb" (12 Sep 2023, 1268 Bytes) of package /linux/www/discourse-3.1.1.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. See also the last Fossies "Diffs" side-by-side code changes report for "002_badges.rb": 3.0.6_vs_3.1.0.

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