Skip to content

Commit

Permalink
Add helper method for decoding deleted record
Browse files Browse the repository at this point in the history
While working on DeletedRecord, we frequently need to find the record from its
ubid. This commit adds a helper method for that.
  • Loading branch information
byucesoy committed May 4, 2024
1 parent 452ef85 commit 17f0af1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/pry
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require_relative "../loader"

require "pry"

Sequel.extension :pg_json_ops

def dev_project
return unless Config.development?
ac = Account[email: "[email protected]"] || Account.create_with_id(email: "[email protected]")
Expand All @@ -17,6 +19,10 @@ def udec(*)
UBID.decode(*)
end

def udec_deleted(ubid)
DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first
end

opts = Pry::CLI.parse_options
Pry.config.prompt_name = if Config.production?
"\e[41m⚠️ %s\e[0m" % "clover-#{Config.rack_env}"
Expand Down

0 comments on commit 17f0af1

Please sign in to comment.