IPC (Interprocess Communication)
- REST w/ JSON - the fashionable choice
- Messaging
Considerations
class InvoicesController < ApplicationController | |
def edit | |
@invoice = Invoice.find(params[:id]) | |
end | |
def update | |
invoice = Invoice.find(params[:id]) | |
invoice.update!(invoice_params) | |
redirect_to invoice |
class Invoice < ActiveRecord::Base | |
validates_presence_of :amount_due, :due_date, :scheduled_send_date | |
validate :closeable_if_unpaid | |
def closeable_if_unpaid | |
if paid_at.present? && closed_at.present? | |
errors.add(:closed_at, "cannot be closed") | |
end | |
end | |
end |
# db/schema.rb | |
create_table "invoices", force: :cascade do |t| | |
t.datetime "closed_at" | |
t.datetime "due_date" | |
t.datetime "paid_at" | |
t.datetime "scheduled_send_date" | |
t.datetime "sent_at" | |
t.integer "amount_due" | |
t.string "invoice_type" | |
end |
class Lesson < Curriculum | |
belongs_to :canonical_material, class_name: CourseWork::CanonicalMaterial | |
has_one :lab, foreign_key: :curriculum_id | |
def lab? | |
if $rollout.active?(:remove_content) | |
canonical_material.lab? | |
else | |
!!lab | |
end |
class AssignedRepo < ActiveRecord::Base | |
def contents | |
if $rollout.active?(:remove_content) | |
raise 'Contents called from assigned repo.' # Remove method when removing :remove_content rollout | |
else | |
return self.none if canonical.nil? | |
canonical.contents | |
end | |
end |
class Track < Curriculum | |
def labs | |
if $rollout.active?(:remove_content) | |
CourseWork::CanonicalMaterial | |
.joins(:lessons) | |
.where(curriculums: {track_id: self.id}) | |
.where(kind: CourseWork::CanonicalMaterial::LAB_KINDS) | |
else | |
Lab.where(track_id: self.id) | |
end |
class Api::V1::SearchesController < ApiController | |
def new | |
gh_id_mappings = if $rollout.active?(:remove_content) | |
GithubRepository.track_data_for_github_repos(repos.pluck(:id), current_user.active_track_id) | |
else | |
GithubRepository.github_id_mappings_for_global_search(current_user) | |
end | |
# omitted | |
end |
# some other caller | |
def set_projects_progress_status! | |
project_repo_ids = AssignedRepo.team_projects_for(batch_id: batch.id, track_id: track.id).pluck(:canonical_id) | |
end | |
def set_projects_progress_status! | |
project_repo_ids = AssignedRepo.team_projects_for(batch_id: batch.id, track_id: track.id).canonical_github_repository_ids | |
end | |
# Assigned Repo |
def completed_labs_count(student, canonical_repo_ids) | |
if $rollout.active?(:remove_content) | |
student.canonical_progresses.complete. | |
joins(github_repository: :canonical_material). | |
where(github_repository_id: canonical_repo_ids). | |
where(kind: CourseWork::CanonicalMaterial::LAB_KINDS). | |
uniq(:id). | |
count | |
else | |
student.canonical_progresses.complete. |