Badge description disappeared in Chinese forum, seed_fu problem?


(Erick Guan) #1

Badge doesn’t show the description at all.

Version: 1.5.0.beta15
DISCOURSE_DEFAULT_LOCALE: zh_CN

https://meta.discoursecn.org/badges/15/第一次引用

(First Quote)

It’s an old installation. The problem is that badge name is not overridden by seed_fu. Without the proper name, it can’t get the i18n key. Therefore, description is not shown.

New badges are doing fine.

#<Badge:0x0055e8cab02a80
 id: 17,
 name: "读者",
 description: "",
 badge_type_id: 3,
 grant_count: 0,
 created_at: Mon, 29 Sep 2014 16:55:53 UTC +00:00,
 updated_at: Sat, 01 Nov 2014 01:42:51 UTC +00:00,
 allow_title: false,
 multiple_grant: false,
 icon: "fa-certificate",
 listable: true,
 target_posts: false,
 query:
  "    SELECT id user_id, current_timestamp granted_at\n    FROM users\n    WHERE id IN\n    (\n      SELECT pt.user_id\n      FROM post_timings pt\n      JOIN badge_posts b ON b.post_number = pt.post_number AND\n                            b.topic_id = pt.topic_id\n      JOIN topics t ON t.id = pt.topic_id\n      LEFT JOIN user_badges ub ON ub.badge_id = 17 AND ub.user_id = pt.user_id\n      WHERE ub.id IS NULL AND t.posts_count > 100\n      GROUP BY pt.user_id, pt.topic_id, t.posts_count\n      HAVING count(*) >= t.posts_count\n    )\n",
 enabled: true,
 auto_revoke: false,
 badge_grouping_id: 1,
 trigger: nil,
 show_posts: false,
 system: true,
 image: "",
 long_description: nil>

(Reader)

I tried:

  1. rake db:seed_fu success but doesn’t change the badge.
  2. Invoked rake task in the console, not effective.
  3. I copied the hash and update_attributes to one old badge. The model is valid but it doesn’t change the record.

(Sam Saffron) #2

ahh… I should add a fallback to en there …


(Erick Guan) #3

Beyond fallback, shouldn’t the badge name changed by seed_fu? I suppose the badge name will follow the new translation


(Erick Guan) #4

Beyond a migration fix, for who might want to manually flush the system badges:

  1. Enter rails console
  2. Make sure your custom badge ids are larger than 100
  3. Badge.where('id < ?', 100).each { |b| b.delete } deletes system badges
  4. Exit console and run rake db:seed_fu. Everything is gonna be fine. Badges counts will be updated later.

(Sam Saffron) #5

Not a seed_fu issue, was a bug in the code, fixed per:


(Sam Saffron) #6