Changes in / [0496e6e:e7bafc0]
- Files:
-
- 1 deleted
- 3 edited
-
docs/Ph8.md (deleted)
-
iknow-api/Program.cs (modified) (1 diff)
-
iknow-api/Services/Implementations/EnrollmentService.cs (modified) (3 diffs)
-
iknow-api/appsettings.Development.json.example (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
iknow-api/Program.cs
r0496e6e re7bafc0 66 66 // Postgres type by name; PgEnumLabels covers the members whose label is not 67 67 // simply the lowercased member name. 68 // AddDbContextPool reuses the DbContext instances themselves; the connections 69 // underneath them are pooled separately by Npgsql, sized in the connection 70 // string. Both matter here because every physical connection is one more 71 // channel through the SSH tunnel. 72 builder.Services.AddDbContextPool<AppDbContext>(options => 68 builder.Services.AddDbContext<AppDbContext>(options => 73 69 options.UseNpgsql( 74 70 builder.Configuration.GetConnectionString("DefaultConnection"), -
iknow-api/Services/Implementations/EnrollmentService.cs
r0496e6e re7bafc0 3 3 using iknow_api.Models; 4 4 using Microsoft.EntityFrameworkCore; 5 using Npgsql;6 5 7 6 namespace iknow_api.Services … … 221 220 }; 222 221 } 223 catch (DbUpdateException ex) when (IsUniqueViolation(ex))224 {225 // Two enrolments for the same semester sent at the same time both226 // pass the check above, because each transaction reads the state227 // from before the other one wrote. UNIQUE (user_id, semester_id)228 // is what actually settles it, so the loser gets the same229 // sentence as if the check had caught it.230 await transaction.RollbackAsync();231 return Fail("You are already enrolled in that semester.");232 }233 222 catch 234 223 { … … 237 226 } 238 227 } 239 240 /// <summary>23505 is unique_violation.</summary>241 private static bool IsUniqueViolation(DbUpdateException ex) =>242 ex.InnerException is PostgresException { SqlState: "23505" };243 228 244 229 private static EnrollSemesterResultDto Fail(string message) => -
iknow-api/appsettings.Development.json.example
r0496e6e re7bafc0 7 7 }, 8 8 "ConnectionStrings": { 9 "DefaultConnection": "Host=localhost;Port=9999;Database=db_202526z_va_prj_know2026;Username=db_202526z_va_prj_iknow2026_owner;Password=YOUR_DB_PASSWORD_HERE;Search Path=project;Include Error Detail=true ;Maximum Pool Size=10;Minimum Pool Size=1;Connection Idle Lifetime=300;Timeout=15"9 "DefaultConnection": "Host=localhost;Port=9999;Database=db_202526z_va_prj_know2026;Username=db_202526z_va_prj_iknow2026_owner;Password=YOUR_DB_PASSWORD_HERE;Search Path=project;Include Error Detail=true" 10 10 }, 11 11 "Jwt": {
Note:
See TracChangeset
for help on using the changeset viewer.
