Week 8 - Overview
Students should be comfortable with the following at the end of this week:
- Indices and Runtime Optimizations
- Mailers
- Background Processing
- File Uploads and S3
Important Links
Monday - SQL and Efficiency
Challenge: Primes
- Human Learning:
- ON BOARD: Use short feedback loops
- Wife and dinner example
- Let’s use them here as we work on primes.
- Runtimes and Primes
- Computational Complexity (
O(n)
, O(lg n)
, O(n^2)
, etc)
- Memory Usage
- Indices
- Example: Build Bank app with branches, clients, accounts, and expenses.
- Massive Seeds
- Database Indices
- Double indices
- Transactions
- Single-field search bar queries (ala Google)
- AREL
- Caching
Lecture Notes/Links
Evening Reading
Assignment
Database Optimizations
Tuesday - All Things Open Conference
Have fun!
Wednesday - Background Processing
Challenge: Double Loop Challenge
- Random Topics
- Polymorphic associations
- AREL:
to_dos = ToDo.arel_table
followed by where(to_dos[:title].matches("%#{search}%").or(to_dos[:title].matches("Default")))
- Swap space
- CSV Writing
- Background Processing
- Example: Bank Report Generation
- Review stacks vs. queues
- Queues in a Database Table
- DelayedJob
- ActiveJob
- Limited amount of information you can pass to a job.
- Background Processing Steps
- Add gems
delayed_job_active_record
& daemons
bundle install
rails generate delayed_job:active_record
rake db:migrate
rails generate job JobName
- Somewhere in our code:
JobName.perform_now(params[:something_important])
- In config/application.rb:
config.active_job.queue_adapter = :delayed_job
config.autoload_paths << Rails.root.join('app/jobs')
bin/delayed_job start
- Somewhere in our code:
JobName.perform_later(params[:something_important])
- When you are done coding:
bin/delayed_job stop
Lecture Notes/Links
Evening Reading
Assignment
Thursday - Mailers
Lecture Notes/Links
Evening Reading
Weekend Assignment
Stack Undertow