Skip to content

Comments

Feature/snt 293 impact data integration#192

Open
michiwend wants to merge 19 commits intomainfrom
feature/SNT-293-impact-data-integration
Open

Feature/snt 293 impact data integration#192
michiwend wants to merge 19 commits intomainfrom
feature/SNT-293-impact-data-integration

Conversation

@michiwend
Copy link
Member

What problem is this PR solving?

Introduce backend-side support for impact data from different providers (currently SwissTPH and IDM).
This PR is still work in progress.

Related JIRA tickets

SNT-293

Changes

The changes come in different (new) layers

  • Provider: Abstraction for the impact provider integrations
  • Service: Orchestration on top of a provider to combine impact data and cost data and build an aggregation response
  • API: Serialisers and Views for fetching impact data by scenario ID

Abstracts the impact provider implementations and supports individual and bulk operations to match impact data. Implementations need so indicate whether they support the bulk operation.
WIP implementation of a SwissTPH impact provider using a PostgreSQL database connection through an unmaged ORM model.
WIP for the IDM impact provider using their PostgreSQL database through an unmaged ORM model.
… account

Currently supports SwissTPH and IDM providers by fixed choices in the model.
A service that operates on top of an impact provider which combines impact data with cost data for a given scenario and builds an aggregated response structure.
Views and serialisers for the impact API.
@michiwend michiwend requested review from Bewi and tdethier February 18, 2026 12:53
Copy link
Contributor

@Bewi Bewi left a comment

Choose a reason for hiding this comment

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

Globally it looks good for current state.
I mainly marked naming that are confusing to someone who didn't code it :D

Also, feels like we can improve a lot the flow to make it more readable, but we can talk about that and do it in later stages.

I'll request changes only for the technical parts.

Copy link
Member

@tdethier tdethier left a comment

Choose a reason for hiding this comment

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

Same global opinion as @Bewi: overall it's good, even though some parts are hard to read (impact service, aggregation and so on)

  • I only read the code, I haven't made the setup and tested this yet because I don't know how to access both new databases
  • I would definitely change the casing everywhere
  • I would definitely add more tests (depending on the urgency, we might skip some of them, but - for instance - we want to make sure that we correctly aggregate values)
  • I would get rid of the serializer that doesn't deserialize anything and just fetches a provider
  • kudos on the nice job though 👍

import django.db.models.deletion


class Migration(migrations.Migration):
Copy link
Member

Choose a reason for hiding this comment

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

Another 0021 was merged on main in the meantime, you should rebase/merge main and recreate this migration, otherwise we'll have a conflict

)


class ImpactService:
Copy link
Member

Choose a reason for hiding this comment

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

We should have tests for everything in this file

Comment on lines +36 to +38
value = serializers.FloatField(allow_null=True)
lower = serializers.FloatField(allow_null=True)
upper = serializers.FloatField(allow_null=True)
Copy link
Member

Choose a reason for hiding this comment

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

Should we use DecimalField instead?

return attrs


class ImpactQuerySerializer(ImpactProviderSerializer):
Copy link
Member

Choose a reason for hiding this comment

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

I agree with Bewi's comments on this serializer and once new checks are done, we should add tests for this serializer

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.

3 participants