-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tagger bot name and description and make the rake task idempotent
* Ticket CV2-3877: Update tagger bot name and description and make the rake task idempotent * Update 202306040000_add_tagger_bot_user.rake Tweak bot description --------- Co-authored-by: Scott Hale <[email protected]>
- Loading branch information
1 parent
29f6be3
commit 0cab2aa
Showing
1 changed file
with
38 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,42 @@ | ||
namespace :check do | ||
namespace :migrate do | ||
desc "Create the Bot user Tagger for the Tagger bot" | ||
task create_tagger_user: :environment do | ||
RequestStore.store[:skip_notifications] = true | ||
namespace :migrate do | ||
desc 'Create the bot user Tagger for the Tagger bot' | ||
task create_tagger_user: :environment do | ||
RequestStore.store[:skip_notifications] = true | ||
|
||
if !BotUser.get_user("tagger").nil? | ||
puts "Tagger user already exists, exiting" | ||
return | ||
end | ||
meedan_team = Team.where(slug: 'meedan').last || Team.new(name: 'Meedan', slug: 'meedan') | ||
meedan_team.skip_notifications = true | ||
meedan_team.skip_clear_cache = true | ||
meedan_team.skip_check_ability = true | ||
meedan_team.save! if meedan_team.id.nil? | ||
|
||
Team.current = meedan_team | ||
tb = BotUser.get_user('tagger') || BotUser.new | ||
tb.login = 'tagger' | ||
tb.name = 'Tagger (in beta)' | ||
tb.set_description 'Automatically tags new items based on existing similar items. This feature is in beta, please consult with the Meedan support team before enabling it.' | ||
File.open(File.join(Rails.root, 'public', 'tagger.png')) do |f| | ||
tb.image = f | ||
end | ||
tb.set_role 'editor' | ||
tb.set_version '0.0.1' | ||
tb.set_source_code_url 'https://github.com/meedan/check-api/blob/develop/app/models/bot/tagger.rb' | ||
tb.set_team_author_id meedan_team.id | ||
tb.set_events [{ 'event' => 'create_project_media', 'graphql' => 'dbid, title, description, type' }] | ||
tb.set_settings [ | ||
{ name: 'auto_tag_prefix', label: 'Emoji prefix', description: 'Emoji to be placed in front of autotags', type: 'string', default: '⚡' }, | ||
{ name: 'threshold', label: 'threshold', description: 'Search similarity threshold (0-100)', type: 'integer', default: 70 }, | ||
{ name: 'ignore_autotags', label: 'Ignore auto-tags?', description:'If enabled, autotags will not be considered in finding the most common tag', type: 'boolean', default: false }, | ||
{ name: 'minimum_count', label: 'Minimum count', description:'Minimum number of times a tag must appear to be applied', type: 'integer', default: 0 } | ||
] | ||
tb.set_approved true | ||
tb['settings']['listed'] = true # Appear on the integrations tab of Check Web | ||
tb.save! | ||
|
||
Team.current = nil | ||
RequestStore.store[:skip_notifications] = false | ||
|
||
meedan_team = Team.where(slug: 'meedan').last || Team.new(name: 'Meedan', slug: 'meedan') | ||
meedan_team.skip_notifications = true | ||
meedan_team.skip_clear_cache = true | ||
meedan_team.skip_check_ability = true | ||
meedan_team.save! | ||
|
||
Team.current = meedan_team | ||
tb = BotUser.new | ||
tb.login = 'tagger' | ||
tb.name = 'Tagger' | ||
tb.set_description 'Add tags to items automatically based on similar items.' | ||
File.open(File.join(Rails.root, 'public', 'tagger.png')) do |f| | ||
tb.image = f | ||
end | ||
tb.set_role 'editor' | ||
tb.set_version '0.0.1' | ||
tb.set_source_code_url 'https://github.com/meedan/check-api/blob/develop/app/models/bot/tagger.rb' | ||
tb.set_team_author_id meedan_team.id | ||
tb.set_events [{"event"=>"create_project_media", "graphql"=>"dbid, title, description, type"}] | ||
tb.set_settings [ | ||
{ name: 'auto_tag_prefix', label: 'Emoji prefix', description: 'Emoji to be placed in front of autotags', type: 'string', default: '⚡' }, | ||
{ name: 'threshold', label: 'threshold', description: 'Search similarity threshold (0-100)', type: 'integer', default: 70 }, | ||
{ name: 'ignore_autotags', label: 'Ignore auto-tags?', description:'If enabled, autotags will not be considered in finding the most common tag', type: 'boolean', default: false }, | ||
{ name: 'minimum_count', label: 'Minimum count', description:'Minimum number of times a tag must appear to be applied', type: 'integer', default: 0 } | ||
] | ||
tb.set_approved true | ||
tb['settings']['listed']=true #Appear on the integrations tab of Check Web | ||
tb.save! | ||
|
||
Team.current = nil | ||
RequestStore.store[:skip_notifications] = false | ||
|
||
puts "Tagger user successfully created" | ||
end | ||
puts 'Tagger bot successfully saved.' | ||
end | ||
end | ||
end | ||
end |