Skip to content

feat: add project grants with dataset-level linkage#1619

Open
cocoon02 wants to merge 1 commit intoHDRUK:devfrom
cocoon02:feature/cruk-project-grants
Open

feat: add project grants with dataset-level linkage#1619
cocoon02 wants to merge 1 commit intoHDRUK:devfrom
cocoon02:feature/cruk-project-grants

Conversation

@cocoon02
Copy link
Copy Markdown

Introduce ProjectGrant identity + ProjectGrantVersion snapshots, extract from dataset version metadata, and link grants to datasets via project_grant_has_dataset. Add API endpoints/resources and wire extraction from DatasetVersionObserver.

Screenshots (if relevant)

Describe your changes

Issue ticket link

Environment / Configuration changes (if applicable)

Requires migrations being run?

If not using the pre-push hook. Confirm tests pass:

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added appropriate unit tests
  • I have created mocks for unit tests (where appropriate)
  • I have added appropriate Behat tests to confirm AC (if applicable)
  • I have added Swagger annotations for new endpoints (if applicable)
  • I have added audit logs for new operation logic (if applicable)
  • I have added new environment variables to the .env.example file (if applicable)
  • I have added new environment variables to terraform repository (if applicable)

Introduce ProjectGrant identity + ProjectGrantVersion snapshots, extract from dataset version metadata, and link grants to datasets via project_grant_has_dataset. Add API endpoints/resources and wire extraction from DatasetVersionObserver.
Comment on lines +16 to +24
$table->string('projectGrantName');
$table->string('leadResearcher')->nullable();
$table->string('leadResearchInstitute')->nullable();

$table->json('grantNumbers')->nullable();

$table->date('projectGrantStartDate')->nullable();
$table->date('projectGrantEndDate')->nullable();
$table->text('projectGrantScope')->nullable();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to be like

project_grant_name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocoon02 Per Dan's comment, all DB fields should maintain snake_case conventions.


protected $table = 'project_grant_versions';

protected $fillable = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnhdruk Is right. Coding standards dictate that internal representations of DB records need to be snake_case. Here we're mixing, @cocoon02

Comment thread config/routes.php
'path' => '/project_grants',
'methodController' => 'ProjectGrantController@index',
'namespaceController' => 'App\Http\Controllers\Api\V1',
'middleware' => [],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these endpoints completely public? No sensitive information that needs guarding?

use Illuminate\Http\Resources\Json\JsonResource;
use App\Models\ProjectGrant;

class ProjectGrantIndexResource extends JsonResource
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, I will add another folder v1 ... vx in Resources and add all the resources related to Controller/Vx. The same can be done with Services, except in the case where we will have general services.

use App\Observers\ProjectGrantObserver;

#[ObservedBy([ProjectGrantObserver::class])]
class ProjectGrant extends Model
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, we need a command who need to fill with current data.

@loki-sinclair-hdruk
Copy link
Copy Markdown
Contributor

@cocoon02 One other thing. We do mandate that every PR comes with functional/unit tests as standard. For some of this, you may need some light demo data, which is acceptable until we action Dan's comment about seeding demo data in another PR.

Copy link
Copy Markdown
Collaborator

@spco spco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments to consider please

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ProjectGrantHasDataset extends Model
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (and in ProjectGrantHasPublication/Tool) it would be more explicit and consistent with our treatment of DatasetVersion to rename to ProjectGrantVersionHasDataset etc please.

//
}

private function reindexLinkedDatasets(int $projectGrantId): void
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least until ProjectGrant is a searchable/indexed field within Datasets, do we need these two Observers? Perhaps I don't see where this reindexing would be necessary if a ProjectGrant or ProjectGrantVersion were to change. Or is this here in expectation that we'll also make ProjectGrant a searchable/indexed field in Elastic and search-service?

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.

4 participants