Skip to content

Enhance error handling and optimize random algorithm for course allocation - #1940

Merged
vikrantwiz02 merged 1 commit into
FusionIIIT:prod/acad-reactfrom
vikrantwiz02:prod/acad-react
Jul 30, 2026
Merged

Enhance error handling and optimize random algorithm for course allocation#1940
vikrantwiz02 merged 1 commit into
FusionIIIT:prod/acad-reactfrom
vikrantwiz02:prod/acad-react

Conversation

@vikrantwiz02

Copy link
Copy Markdown
Member

This pull request significantly optimizes the course allocation logic in the academic information system by reducing the number of database queries and improving performance. The main changes involve batching queries and using bulk operations to replace inefficient per-object lookups and inserts, which should lead to faster allocations and less database load.

Performance and Query Optimization:

  • In random_algo, replaced per-course and per-student queries with batched queries and precomputed dictionaries for course capacities, already allotted seats, student-curriculum mappings, and semester lookups. This reduces the number of queries from many per iteration to just a few per allocation run.
  • In random_algo, switched from creating FinalRegistration objects one at a time to collecting them in a list and using bulk_create at the end, greatly improving insert performance.
  • In allocate, replaced multiple queries per student with a single batched query per slot, and used dictionaries to map students to curricula and semesters. Final registrations are now inserted in bulk for each slot.

Code Simplification and Consistency:

  • Simplified the way student and course relationships are handled by using ID-based lookups and bulk operations, making the code easier to maintain and less error-prone. [1] [2] [3]

Error Handling Improvement:

  • Improved exception logging in start_allocation_api by logging the exception with a traceback and returning a more informative error message including the exception type.

@vikrantwiz02
vikrantwiz02 merged commit 4c8f7db into FusionIIIT:prod/acad-react Jul 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant