Skip to content

Change adaptors architecture #104

Description

@mjeammet

Context

Inherited from previous app, we have an Indicator model with whom I have several issues:

  • the indicateur field
  • ambiguity : these objects are indicators (as in "a type of measurement of product's usage") and, at the same time, a specific instance of said measurement

and all methods are hardcoded and called one by one whenever we need to add new instances of said indicator.

Proposition

Architectural changes to adaptors, based on people's webhooks.

We'd go from an structure with only Indicator model and hardcoded client methods to

  • A Client class for each type of source (e.g. Metabase, Posthog, datagouv, direct API calls)
  • An Adaptor model, describing how to create Records of an Indicator, using a Client
  • Records instead of Indicators for single instances of measurement
    • create Record models and migrate all infos from existing Indicators
    • create CRUD for records, below related Indicator
  • And maybe, merge Adaptor and Indicator into a single model, because they have the same function ?
    • They have kind of the same function but for cases where a single Client is linked to several Indicators (i.e. LaSuite or FranceTransfert), I can't have a 1-1 relationship between these two models

In the end, each Product have several Indicators, whom evolution is tracked by listing Records.
These records are fetched and saved according to Indicators' Adaptor info, linking an Indicator to the right method in a Client

Implem

Notes from where I was very confused about it all

`

class Adaptor :
foreign key = product
client = method 
url = string
options = {"option1: bla"}
last_successful  = date
last_run = date

et/ou potentiellement :

class Indicator :
product = foreign key  product 
method = adaptor
frequence = daily / weekly / monthly / yearly
count relevés = value
dernier relevé = value
unit = string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions