Skip to content

fix(draft): reuse the study-backed project when drafts have duplicate rows - #1544

Open
vcnainala wants to merge 2 commits into
developmentfrom
fix/draft-project-reuse
Open

fix(draft): reuse the study-backed project when drafts have duplicate rows#1544
vcnainala wants to merge 2 commits into
developmentfrom
fix/draft-project-reuse

Conversation

@vcnainala

Copy link
Copy Markdown
Member

Summary

  • Resolve the draft project that already has studies instead of Project::where('draft_id')->first(), which could pick an empty sibling from retries or concurrent process requests.
  • Reassign existing studies (and their samples/datasets) onto the project used by the current process run, and return JSON 422 instead of a redirect when no studies exist.
  • Score validation against the requested project (or the associated project with studies). A second commit makes associated-article DOI optional at publish time while still requiring at least one citation in project mode.

Laravel 13 notes: constructor-injected ProcessDraft on UploadController, explicit Response|JsonResponse return types, named process(project:) argument, and HasMany projects() alongside the existing hasOne project(). This app does not use Filament.

Test plan

  • Process a draft that has an empty extra project row and confirm the UI keeps the project that already has studies.
  • Publish that draft and confirm validation reports those studies.
  • Process a draft with no instrument files and confirm a JSON 422 (no Inertia redirect).
  • Publish a project-mode dataset whose citation has no DOI and confirm validation still passes if a citation exists.
  • php artisan test --filter='ProcessDraftProjectReuseTest|ProjectValidationTest|UploadTest|ValidationModelTest|PublishProjectTest|PublishEmbargoProjectValidationTest'

… rows

Retries and concurrent process requests can leave extra empty project rows. Resolve and validate the project that already has studies, and return JSON 422 when none exist.
…time

Require at least one citation in project mode, but do not fail validation when a citation has no DOI.
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.50%. Comparing base (8681915) to head (9f516c1).

Files with missing lines Patch % Lines
app/Actions/Draft/FindOrCreateDraftStudy.php 50.00% 4 Missing ⚠️
app/Actions/Draft/ProcessDraft.php 92.59% 2 Missing ⚠️
app/Http/Controllers/DraftController.php 77.77% 2 Missing ⚠️
app/Http/Controllers/ProjectController.php 80.00% 1 Missing ⚠️
app/Jobs/ValidateAndSubmitELNDraft.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             development    #1544      +/-   ##
=================================================
+ Coverage          80.26%   80.50%   +0.24%     
- Complexity          4481     4488       +7     
=================================================
  Files                293      293              
  Lines              16424    16473      +49     
=================================================
+ Hits               13182    13261      +79     
+ Misses              3242     3212      -30     
Flag Coverage Δ
unittests 80.50% <88.88%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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