-
Notifications
You must be signed in to change notification settings - Fork 19
Active Record Queries Resource
Yoom Lam edited this page Jun 29, 2021
·
12 revisions
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'")
- Home
- Acronyms and Glossary
- Caseflow products
- Caseflow Intake
- Caseflow Queue
- Appeals Consumer
- Caseflow Reader
- Caseflow eFolder
- Caseflow Hearings
- Caseflow Certification
- Caseflow APIs
- Appeal Status API
- Caseflow Dispatch
-
CSUM Roles
- System Admin
- VHA Team Management
- Active Record Queries Resource
- External Integrations
- Caseflow Demo
- Caseflow ProdTest
- Background
- Stuck Jobs
- VA Notify
-
Caseflow-Team
- Tier 4
- Bat Team
- Technical Documentation
- Backend Code Patterns
- Backend Working Group
- FACOLS, VACOLS DB Schema
- Asyncable Models
- External Data: where and why
- Data Fetching Scripts
- Caseflow Data Model and Dictionary
- User Access Permissions
- Controller Schemas
- Constants
- Frontend Best Practices
- Accessibility
- How-To
- Debugging Tips
- Adding a Feature Flag with FeatureToggle
- Editing AMA issues
- Editing a decision review
- Fixing task trees
- Investigating and diagnosing issues
- Data and Metric Request Workflow
- Exporting and Importing Appeals
- Explain page for Appeals
- Record associations and Foreign Keys
- Upgrading Ruby
- Stuck Appeals
- Testing Action Mailer Messages Locally
- Re-running Seed Files
- Rake Generator for Legacy Appeals
- Manually running Scheduled Jobs
- System Admin UI
- Caseflow Makefile
- Upgrading Postgresql from v11.7 to v14.8 Locally
- VACOLS VM Trigger Fix M1
- Using SlackService to Send a Job Alert
- Technical Talks