studysystem 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. studysystem/__init__.py +1 -0
  2. studysystem/assets/note-callouts.lua +100 -0
  3. studysystem/assets/note-no-html.lua +28 -0
  4. studysystem/assets/note.css +146 -0
  5. studysystem/cli.py +344 -0
  6. studysystem/dashboard.html +781 -0
  7. studysystem/dashboard.py +377 -0
  8. studysystem/db/__init__.py +1 -0
  9. studysystem/db/engine.py +158 -0
  10. studysystem/db/migrate.py +122 -0
  11. studysystem/db/migrations/env.py +59 -0
  12. studysystem/db/migrations/script.py.mako +29 -0
  13. studysystem/db/migrations/versions/0000_baseline.py +19 -0
  14. studysystem/db/migrations/versions/0001_the_whole_schema.py +1743 -0
  15. studysystem/db/migrations/versions/0002_semester_ignores_case.py +38 -0
  16. studysystem/db/migrations/versions/0003_course_vault_folder.py +26 -0
  17. studysystem/db/migrations/versions/0004_note_pdf_path.py +26 -0
  18. studysystem/db/migrations/versions/0005_tagging_kind.py +39 -0
  19. studysystem/db/migrations/versions/0006_practice_mode.py +36 -0
  20. studysystem/db/migrations/versions/0007_exam_prep_from.py +25 -0
  21. studysystem/db/migrations/versions/0008_more_papers_kind.py +37 -0
  22. studysystem/db/migrations/versions/0009_past_exam_month_date.py +28 -0
  23. studysystem/db/migrations/versions/0010_task_parts.py +70 -0
  24. studysystem/db/migrations/versions/0011_observation_kind.py +39 -0
  25. studysystem/db/migrations/versions/0012_profile_claim.py +52 -0
  26. studysystem/db/migrations/versions/0013_assumed_instructor_papers.py +40 -0
  27. studysystem/db/migrations/versions/0014_scan_confirmation.py +44 -0
  28. studysystem/db/migrations/versions/0015_practice_item_count.py +37 -0
  29. studysystem/db/migrations/versions/0016_timetable_patterns.py +102 -0
  30. studysystem/db/migrations/versions/0017_course_dropped.py +36 -0
  31. studysystem/db/migrations/versions/0018_syllabus_topics.py +82 -0
  32. studysystem/db/migrations/versions/0019_course_lab_group.py +36 -0
  33. studysystem/db/migrations/versions/0020_chapter_scope.py +61 -0
  34. studysystem/db/migrations/versions/0021_note_retired_at.py +28 -0
  35. studysystem/db/migrations/versions/0022_rescope.py +48 -0
  36. studysystem/db/migrations/versions/0023_backlog_reason.py +42 -0
  37. studysystem/db/migrations/versions/0024_guess_sensitivity.py +35 -0
  38. studysystem/db/migrations/versions/0025_shortfall_inputs.py +83 -0
  39. studysystem/db/migrations/versions/0026_trials_switch.py +36 -0
  40. studysystem/db/tables.py +1096 -0
  41. studysystem/demo.py +722 -0
  42. studysystem/errors.py +39 -0
  43. studysystem/server/__init__.py +83 -0
  44. studysystem/server/__main__.py +5 -0
  45. studysystem/services/__init__.py +1 -0
  46. studysystem/services/adherence.py +147 -0
  47. studysystem/services/assessments.py +171 -0
  48. studysystem/services/capacity.py +164 -0
  49. studysystem/services/claims.py +405 -0
  50. studysystem/services/course_folder.py +82 -0
  51. studysystem/services/courses.py +176 -0
  52. studysystem/services/coverage.py +121 -0
  53. studysystem/services/dashboard_key.py +102 -0
  54. studysystem/services/feedback.py +412 -0
  55. studysystem/services/forward_eval.py +65 -0
  56. studysystem/services/gate.py +77 -0
  57. studysystem/services/generation.py +2864 -0
  58. studysystem/services/ids.py +15 -0
  59. studysystem/services/intake.py +278 -0
  60. studysystem/services/launcher.py +455 -0
  61. studysystem/services/lookups.py +91 -0
  62. studysystem/services/materials.py +97 -0
  63. studysystem/services/note_markdown.py +241 -0
  64. studysystem/services/notes.py +396 -0
  65. studysystem/services/parts.py +65 -0
  66. studysystem/services/past_exams.py +115 -0
  67. studysystem/services/pdf_render.py +148 -0
  68. studysystem/services/pdf_worker.py +184 -0
  69. studysystem/services/plan.py +1300 -0
  70. studysystem/services/private_view.py +38 -0
  71. studysystem/services/profiles.py +544 -0
  72. studysystem/services/programs.py +16 -0
  73. studysystem/services/replacements.py +107 -0
  74. studysystem/services/rescope.py +277 -0
  75. studysystem/services/settings.py +50 -0
  76. studysystem/services/setup.py +235 -0
  77. studysystem/services/shortfall.py +443 -0
  78. studysystem/services/state.py +846 -0
  79. studysystem/services/statements.py +222 -0
  80. studysystem/services/study_loop.py +998 -0
  81. studysystem/services/summaries.py +369 -0
  82. studysystem/services/syllabus.py +138 -0
  83. studysystem/services/system_work.py +113 -0
  84. studysystem/services/taxonomy.py +459 -0
  85. studysystem/services/topics.py +477 -0
  86. studysystem/services/trials.py +201 -0
  87. studysystem/services/unconfirmed.py +95 -0
  88. studysystem/services/units.py +34 -0
  89. studysystem/services/users.py +53 -0
  90. studysystem/services/values.py +168 -0
  91. studysystem/startup.py +147 -0
  92. studysystem/tools/__init__.py +4 -0
  93. studysystem/tools/course_setup.py +185 -0
  94. studysystem/tools/dashboard.py +27 -0
  95. studysystem/tools/feedback.py +66 -0
  96. studysystem/tools/gate.py +24 -0
  97. studysystem/tools/generation.py +156 -0
  98. studysystem/tools/materials.py +32 -0
  99. studysystem/tools/notes.py +29 -0
  100. studysystem/tools/past_exams.py +51 -0
  101. studysystem/tools/ping.py +9 -0
  102. studysystem/tools/plan.py +40 -0
  103. studysystem/tools/profiles.py +94 -0
  104. studysystem/tools/results.py +77 -0
  105. studysystem/tools/study_loop.py +145 -0
  106. studysystem/tools/summaries.py +52 -0
  107. studysystem/tools/topics.py +143 -0
  108. studysystem-1.0.0.dist-info/METADATA +254 -0
  109. studysystem-1.0.0.dist-info/RECORD +112 -0
  110. studysystem-1.0.0.dist-info/WHEEL +4 -0
  111. studysystem-1.0.0.dist-info/entry_points.txt +3 -0
  112. studysystem-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,59 @@
1
+ """Alembic entry point. Runs every migration on a connection from our own engine, so the
2
+ PRAGMAs (foreign_keys, WAL, busy_timeout) and BEGIN IMMEDIATE apply here too."""
3
+
4
+ from alembic import context
5
+
6
+ from studysystem.db.engine import db_path, make_engine
7
+ from studysystem.db.tables import metadata
8
+
9
+ # What the code believes the database looks like; `alembic revision --autogenerate` diffs the
10
+ # migrations against it.
11
+ target_metadata = metadata
12
+
13
+
14
+ def run_migrations() -> None:
15
+ config = context.config
16
+ # `study migrate` hands us its engine; the bare `alembic` CLI (dev only) gets a fresh one.
17
+ engine = config.attributes.get("engine") or make_engine(db_path())
18
+
19
+ with engine.connect() as connection:
20
+ # SQLite (D-103): batch mode rebuilds a table as copy -> drop -> rename, and with foreign
21
+ # keys enforced the drop of a parent table fails against its children - RESTRICT fires
22
+ # even when deferred. `foreign_keys = OFF` is a no-op inside a transaction, so it is set
23
+ # here, on the raw connection, before the run's transaction opens. Postgres alters in
24
+ # place and needs none of it: `raw` is the sqlite3 connection underneath, or None on
25
+ # Postgres.
26
+ sqlite = connection.dialect.name == "sqlite"
27
+ raw = connection.connection.driver_connection if sqlite else None
28
+ if raw is not None:
29
+ raw.execute("PRAGMA foreign_keys = OFF")
30
+ try:
31
+ # The run's one transaction, opened here. Left to itself, Alembic treats SQLite's DDL
32
+ # as non-transactional and commits after every migration, so the check below would
33
+ # run after the last commit and undo nothing. A transaction already open when
34
+ # `configure` runs is the caller's: Alembic opens none of its own inside it.
35
+ with connection.begin():
36
+ context.configure(
37
+ connection=connection,
38
+ target_metadata=target_metadata,
39
+ render_as_batch=True, # SQLite alters a table by rebuilding it (D-08)
40
+ )
41
+ context.run_migrations()
42
+ if raw is not None:
43
+ # The check the run skipped, once, before COMMIT: a row pointing at a
44
+ # missing id raises, and the whole run rolls back.
45
+ dangling = connection.exec_driver_sql("PRAGMA foreign_key_check").fetchall()
46
+ if dangling:
47
+ raise RuntimeError(
48
+ f"migration left rows pointing at missing ids: {dangling[:5]}"
49
+ )
50
+ finally:
51
+ # The connection goes back to the pool, and every pooled connection enforces them.
52
+ # The run has committed by now, but SQLAlchemy may hold a fresh, empty transaction
53
+ # open - inside it the PRAGMA would be a no-op again - so end it first.
54
+ if raw is not None:
55
+ connection.rollback()
56
+ raw.execute("PRAGMA foreign_keys = ON")
57
+
58
+
59
+ run_migrations()
@@ -0,0 +1,29 @@
1
+ """${message}
2
+
3
+ Revision ID: ${up_revision}
4
+ Revises: ${down_revision | comma,n}
5
+ Create Date: ${create_date}
6
+ """
7
+
8
+ import sqlalchemy as sa
9
+ from alembic import op
10
+ ${imports if imports else ""}
11
+
12
+ revision = ${repr(up_revision)}
13
+ down_revision = ${repr(down_revision)}
14
+ branch_labels = ${repr(branch_labels)}
15
+ depends_on = ${repr(depends_on)}
16
+
17
+
18
+ # Batch mode rebuilds a table by reflecting it, and SQLAlchemy cannot reflect an expression
19
+ # index: rebuilding `course`, `topic` or `assessment_slot` silently drops ux_course_code,
20
+ # ux_topic_live or ux_assessment_slot_name (the "Skipped unsupported reflection" SAWarning).
21
+ # A migration that rebuilds one of them recreates its index after the batch block.
22
+
23
+
24
+ def upgrade() -> None:
25
+ ${upgrades if upgrades else "pass"}
26
+
27
+
28
+ def downgrade() -> None:
29
+ ${downgrades if downgrades else "pass"}
@@ -0,0 +1,19 @@
1
+ """baseline: empty schema
2
+
3
+ Revision ID: 0000
4
+ Revises:
5
+ Create Date: 2026-09-17
6
+ """
7
+
8
+ revision = "0000"
9
+ down_revision = None
10
+ branch_labels = None
11
+ depends_on = None
12
+
13
+
14
+ def upgrade() -> None:
15
+ pass
16
+
17
+
18
+ def downgrade() -> None:
19
+ pass