Active Record Queries Resource - TISTATechnologies/caseflow GitHub Wiki
Here is a consolidated guide resource for Active Record Queries. Also check out Rails Console Code Snippets.
UAT
ssm certification uat auto
sudo su -c "source /opt/caseflow-certification/caseflow-certification_env.sh; cd /opt/caseflow-certification/src; bin/rails c"
Prod
ssm certification prod auto
sudo su -c "source /opt/caseflow-certification/caseflow-certification_env.sh; cd /opt/caseflow-certification/src; bin/rails c"
Code snippet
RequestStore[:current_user] = User.system_user
uuid = "" # Add uuid here
appeal = Appeal.find_by(uuid: uuid)
appeal.treee # Prints out appeal tree
All vacate streams for an appeal have the same docket number. Therefore, to find the post-decision motions related to that docket number:
Code snippet
appeal = Appeal.find_by_uuid(uuid)
PostDecisionMotion.where(appeal: Appeal.where(stream_docket_number: appeal.docket_number).all)
Alternatively, if you know you have the original appeal and specifically want post-decision motions started from that appeal:
Code snippet
appeal = Appeal.find_by_uuid(uuid)
PostDecisionMotion.where(task: appeal.tasks)
Code snippet
cases = VACOLS::Case.joins(:folder).where("folder.tinum": docket_number)
vacols_ids = cases.map(&:id)
legacy_appeals = LegacyAppeal.where(vacols_id: vacols_ids)
Code snippet
FactoryBot.create(:NAME_OF_FACTORY)
#example
FactoryBot.create(:bgs_attorney)
Code snippet
If you know the user's CSS ID, this find-by method takes care of the upper-casing:
User.find_by_css_id("bvaaabshire")
If you only know their name, and perhaps aren't sure of their formal first name, use LIKE
or case-insensitive ILIKE
to get a list of possible matches:
User.where("full_name ILIKE '% abshire'")
User.where("full_name ILIKE 'jo% smith'")