This is an automated email from the ASF dual-hosted git repository.
kumfo pushed a commit to branch feat/1.4.0/badge
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
The following commit(s) were added to refs/heads/feat/1.4.0/badge by this push:
new dc56fce1 feat(badge): init version update
dc56fce1 is described below
commit dc56fce18a89e0fa2f1dfe89df65ee1c0aea5be4
Author: kumfo <[email protected]>
AuthorDate: Thu Aug 1 11:19:21 2024 +0800
feat(badge): init version update
---
i18n/en_US.yaml | 249 ++++++++++++++++++++++++++++++++++++++++++++-
internal/migrations/v22.go | 184 +++++++++++++++++++++++++++++++++
2 files changed, 432 insertions(+), 1 deletion(-)
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index a123d70d..bfe53305 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -421,7 +421,7 @@ backend:
tags_title:
other: Tags
no_description:
- other: The tag has no description.
+ other: The tag has no description.
notification:
action:
update_question:
@@ -526,6 +526,253 @@ backend:
reaction:
tooltip:
other: "{{ .Names }} and {{ .Count }} more..."
+ badge:
+ badges:
+ autobiographer:
+ name:
+ other: Autobiographer
+ desc:
+ other: Filled out [profile] information.
+ certified:
+ name:
+ other: Certified
+ desc:
+ other: Completed our new user tutorial.
+ editor:
+ name:
+ other: Editor
+ desc:
+ other: First post edit.
+ first_flag:
+ name:
+ other: First Flag
+ desc:
+ other: First flagged a post.
+ first_upvote:
+ name:
+ other: First Upvote
+ desc:
+ other: First up voted a post.
+ first_link:
+ name:
+ other: First Link
+ desc:
+ other: First dirst added a link to another post.
+ first_reaction:
+ name:
+ other: First Reaction
+ desc:
+ other: First reacted to the post.
+ first_share:
+ name:
+ other: First Share
+ desc:
+ other: First shared a post.
+ scholar:
+ name:
+ other: Scholar
+ desc:
+ other: Asked a question and accepted an answer.
+ commentator:
+ name:
+ other: Commentator
+ desc:
+ other: Leave 5 comments.
+ new_user_of_the_month:
+ name:
+ other: New User of the Month
+ desc:
+ other: Outstanding contributions in their first month.
+ read_guidelines:
+ name:
+ other: Read Guidelines
+ desc:
+ other: Read the [community guidelines].
+ reader:
+ name:
+ other: Reader
+ desc:
+ other: Read every answers in a topic with more than 10 answers.
+ welcome:
+ name:
+ other: Welcome
+ desc:
+ other: Received a up vote.
+ nice_share:
+ name:
+ other: Nice Share
+ desc:
+ other: Shared a post with 25 unique visitors.
+ good_share:
+ name:
+ other: Good Share
+ desc:
+ other: Shared a post with 300 unique visitors.
+ great_share:
+ name:
+ other: Great Share
+ desc:
+ other: Shared a post with 1000 unique visitors.
+ out_of_love:
+ name:
+ other: Out of Love
+ desc:
+ other: Used 50 up votes in a day.
+ higher_love:
+ name:
+ other: Higher Love
+ desc:
+ other: Used 50 up votes in a day 5 times.
+ crazy_in_love:
+ name:
+ other: Crazy in Love
+ desc:
+ other: Used 50 up votes in a day 20 times.
+ promoter:
+ name:
+ other: Promoter
+ desc:
+ other: Invited a user.
+ campaigner:
+ name:
+ other: Campaigner
+ desc:
+ other: Invited 3 basic users.
+ champion:
+ name:
+ other: Champion
+ desc:
+ other: Invited 5 members.
+ thank_you:
+ name:
+ other: Thank You
+ desc:
+ other: Has 20 up voted posts and gave 10 up votes.
+ gives_back:
+ name:
+ other: Gives Back
+ desc:
+ other: Has 100 up voted posts and gave 100 up votes.
+ empathetic:
+ name:
+ other: Empathetic
+ desc:
+ other: Has 500 up voted posts and gave 1000 up votes.
+ enthusiast:
+ name:
+ other: Enthusiast
+ desc:
+ other: Visited 10 consecutive days.
+ aficionado:
+ name:
+ other: Aficionado
+ desc:
+ other: Visited 100 consecutive days.
+ devotee:
+ name:
+ other: Devotee
+ desc:
+ other: Visited 365 consecutive days.
+ anniversary:
+ name:
+ other: Anniversary
+ desc:
+ other: Active member for a year, posted at least once.
+ appreciated:
+ name:
+ other: Appreciated
+ desc:
+ other: Received 1 up vote on 20 posts.
+ respected:
+ name:
+ other: Respected
+ desc:
+ other: Received 2 up votes on 100 posts.
+ admired:
+ name:
+ other: Admired
+ desc:
+ other: Received 5 up votes on 300 posts.
+ solved:
+ name:
+ other: Solved
+ desc:
+ other: Have an answer be accepted.
+ guidance_counsellor:
+ name:
+ other: Guidance Counsellor
+ desc:
+ other: Have 10 answers be accepted.
+ know_it_all:
+ name:
+ other: Know-it-All
+ desc:
+ other: Have 50 answers be accepted.
+ solution_institution:
+ name:
+ other: Solution Institution
+ desc:
+ other: Have 150 answers be accepted.
+ nice_answer:
+ name:
+ other: Nice Answer
+ desc:
+ other: Answer score of 10 or more.
+ good_answer:
+ name:
+ other: Good Answer
+ desc:
+ other: Answer score of 25 or more.
+ great_answer:
+ name:
+ other: Great Answer
+ desc:
+ other: Answer score of 50 or more.
+ nice_question:
+ name:
+ other: Nice Question
+ desc:
+ other: Question score of 10 or more.
+ good_question:
+ name:
+ other: Good Question
+ desc:
+ other: Question score of 25 or more.
+ great_question:
+ name:
+ other: Great Question
+ desc:
+ other: Question score of 50 or more.
+ popular_question:
+ name:
+ other: Popular Question
+ desc:
+ other: Question with 500 views.
+ notable_question:
+ name:
+ other: Notable Question
+ desc:
+ other: Question with 1,000 views.
+ famous_question:
+ name:
+ other: Famous Question
+ desc:
+ other: Question with 5,000 views.
+ popular_link:
+ name:
+ other: Popular Link
+ desc:
+ other: Posted an external link with 50 clicks.
+ hot_link:
+ name:
+ other: Hot Link
+ desc:
+ other: Posted an external link with 300 clicks.
+ famous_link:
+ name:
+ other: Famous Link
+ desc:
+ other: Posted an external link with 100 clicks.
# The following fields are used for interface presentation(Front-end)
ui:
diff --git a/internal/migrations/v22.go b/internal/migrations/v22.go
new file mode 100644
index 00000000..20b1eb3c
--- /dev/null
+++ b/internal/migrations/v22.go
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package migrations
+
+import (
+ "context"
+ "github.com/apache/incubator-answer/internal/entity"
+ "time"
+ "xorm.io/xorm"
+)
+
+var (
+ defaultBadgeGroupTable = []*entity.BadgeGroup{
+ {ID: "1", Name: "Getting Started"},
+ {ID: "2", Name: "Community"},
+ {ID: "3", Name: "Posting"},
+ }
+
+ defaultBadgeTable = []*entity.Badge{
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.autobiographer.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.autobiographer.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.editor.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.editor.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "question",
+ Handler: "FirstQuestion",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.first_flag.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.first_flag.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.first_upvote.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.first_upvote.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.first_reaction.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.first_reaction.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.first_share.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.first_share.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.scholar.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.scholar.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 1,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ {
+ CreatedAt: time.Now(),
+ UpdatedAt: time.Now(),
+ Name: "badge.badges.solved.name",
+ Icon: "",
+ AwardCount: 0,
+ Description: "badge.badges.solved.desc",
+ Status: entity.BadgeStatusAvailable,
+ BadgeGroupId: 2,
+ Level: entity.BadgeLevelBronze,
+ Single: entity.BadgeSingleAward,
+ Collect: "",
+ Handler: "",
+ Param: "",
+ },
+ }
+)
+
+func addBadges(ctx context.Context, x *xorm.Engine) (err error) {
+ // create table
+ err = x.Context(ctx).Sync(new(entity.Badge))
+ if err != nil {
+ return
+ }
+
+ err = x.Context(ctx).Sync(new(entity.BadgeGroup))
+ if err != nil {
+ return
+ }
+
+ err = x.Context(ctx).Sync(new(entity.BadgeAward))
+ if err != nil {
+ return
+ }
+
+ // insert default data
+ _, err = x.Context(ctx).Insert(defaultBadgeGroupTable)
+ if err != nil {
+ return
+ }
+ _, err = x.Context(ctx).Insert(defaultBadgeTable)
+ return
+}