Add stage command to assign workflows to cards

This commit is contained in:
Jorge Manrubia
2025-06-26 00:42:17 +02:00
parent 6f015feee6
commit 0765116779
20 changed files with 8888 additions and 1 deletions
+12
View File
@@ -39,6 +39,8 @@ class Command::Parser
Command::GetInsight.new(query: combined_arguments, card_ids: cards.ids)
when "/search"
Command::Search.new(terms: combined_arguments)
when "/stage"
Command::Stage.new(stage_id: stage_from(combined_arguments)&.id, card_ids: cards.ids)
when "/visit"
Command::VisitUrl.new(url: command_arguments.first)
when "/tag"
@@ -62,6 +64,16 @@ class Command::Parser
User.all.find { |user| user.mentionable_handles.include?(string_without_at) }
end
def stage_from(combined_arguments)
candidate_stages.find do |stage|
stage.name.downcase.include?(combined_arguments.downcase)
end
end
def candidate_stages
Workflow::Stage.where(workflow_id: cards.joins(:collection).select("collections.workflow_id").distinct)
end
def tag_title_from(string)
string.gsub(/^#/, "")
end