Assignment System - FreeUKGen/MyopicVicar GitHub Wiki

Assignment System

Part of Transcriber & Coordinator Workflow. Also see Image-Server-System โ€” Assignment only exists to route work through the image-transcription pipeline described there.

Model: app/models/assignment.rb ยท Controller: app/controllers/assignments_controller.rb

FreeREG's image-transcription work-assignment system: Assignment#heading_info_for_transcriber_request/heading_info_for_sc_request walk Source โ†’ Register โ†’ Church โ†’ Place, all FreeREG parish-register models โ€” there is no template_set/freecen gating anywhere in assignment.rb or assignments_controller.rb. A syndicate coordinator (SC) allocates specific ImageServerImages from an ImageServerGroup to a transcriber or reviewer by creating an Assignment; the transcriber/reviewer works through it and submits for confirmation; the SC finalizes or unassigns. Two independent tracks โ€” transcribe and review โ€” run through the same status field on each image.

Status lifecycle

The authoritative status codes live on ImageServerImage.status (enum defined in SourceProperty::STATUS/STATUS_ARRAY, not in this model). The rough chain:

u (unallocated) โ†’ ar (allocation requested) โ†’ a (allocated, available)
  โ†’ bt (assigned to transcriber, in progress) โ†’ ts (submitted) โ†’ t (transcribed/confirmed)
  โ†’ br (assigned to reviewer, in progress) โ†’ rs (submitted) โ†’ r (reviewed/confirmed)
  โ†’ cs (completion submitted to county coordinator) โ†’ c (complete, terminal)

Unassign/reassign paths jump back down this chain (e.g. unassign from bt โ†’ back to a).

Relationships

Assignment belongs_to :source, :syndicate, :userid_detail, has_many :image_server_images. Assignment.create_assignment(source_id, user_id, instructions, assign_list, image_status) looks up the transcriber's syndicate from their UseridDetail and stamps it onto the assignment, then bulk-attaches the chosen images with the right status via assign_image_server_image_to_assignment.

Naming footgun: my_own

bulk_update_assignment(my_own, ...) and related methods use a my_own parameter whose meaning is the opposite of what it reads as: per the code's own comments, if my_own is the syndicate coordinator's path (# from SC) and the else branch is the transcriber's path (# from transcriber). Read it as "is this update happening from the SC's own management view" rather than "is this the transcriber's own work" โ€” easy to misread, worth double-checking every time you touch this code. session[:my_own] (set in AssignmentsController#my_own, the "view my own assignments" action) is the same flag threaded through update/heading_info.

List-building helpers

filter_assignments_by_userid/filter_assignments_by_assignment_id/list_assignment_by_status don't use Mongoid associations for their list views โ€” they hand-build nested hashes via .pluck and shared prepare_for_parsing/generate_parsing_assignment helpers. Dense and easy to get lost in, but consistent across the file โ€” a deliberate (if dated) performance choice rather than an accident.

Confirmed bug: AssignmentsController#destroy

def destroy
  userids_and_transcribers
  heading_info

  Assignment.update_image_server_image_to_destroy_assignment(params[:id], params[:assign_type])

  assignment_image_count = ImageServerImage.where(assignment_id: assignment_id).first
  assignment.destroy if assignment_image_count.blank?
  ...

assignment_id and assignment are never assigned anywhere in this method โ€” confirmed directly, not just inferred. Calling this action raises NameError: undefined local variable or method. This is a genuinely broken, presumably never-exercised code path, not intentional behavior โ€” worth fixing (likely meant params[:id] and Assignment.find(params[:id])) before relying on it.

Routes

resources :assignments plus ~12 custom routes (config/routes.rb:660-673): assign, re_assign, select_user, list_assignments_by_syndicate_coordinator, list_assignments_of_myself, list_assignment_image(s), list_submitted_transcribe_assignments, list_submitted_review_assignments, my_own, image_completed (routed singular โ€” assignment/image_completed, inconsistent with the plural used everywhere else), select_county, and a list_by_syndicate route with no matching controller action (likely dead).