solgenomics / sgn

The code behind the Sol Genomics Network, Cassavabase and other Breedbase websites
https://solgenomics.net
MIT License
66 stars 35 forks source link

BrAPI /observationUnits returning duplicate plots #5196

Closed dwaring87 closed 1 week ago

dwaring87 commented 2 weeks ago

Expected Behavior

The BrAPI /observationUnits endpoint is returning multiple entries for the same plot if the trial has management factors. It returns one instance of the plot for each management factor applied to the plot.

For example:

A trial with 100 plots returns 1600 entries in the response

{
  "result": {
    "data": [
      {
        "observationUnitName": "Cornell_OatPeaDensity_2023_Ithaca-PLOT_1"
        "treatments": [
          {
            "modality": "No description",
            "factor": "Cornell_OatPeaDensity_2023_Ithaca_oat_density_100"
          }
        ],
        ...
      },
      {
        "observationUnitName": "Cornell_OatPeaDensity_2023_Ithaca-PLOT_1"
        "treatments": [
          {
            "factor": "Cornell_OatPeaDensity_2023_Ithaca_pea_genotype_AUSTRIAN FIELD PEAS",
            "modality": "No description"
          }
        ],
        ...
      },
      {
        "observationUnitName": "Cornell_OatPeaDensity_2023_Ithaca-PLOT_1",
        "treatments": [
          {
            "modality": null,
            "factor": "No ManagementFactor"
          }
        ],
        ...
      },
      {
        "observationUnitName": "Cornell_OatPeaDensity_2023_Ithaca-PLOT_1",
        "treatments": [
          {
            "modality": "No description",
            "factor": "Cornell_OatPeaDensity_2023_Ithaca_pea_density_50"
          }
        ],
        ...
      },
      ...
    ]
  }
  "metadata": {
    "datafiles": [],
    "status": [
      {
        "messageType": "INFO",
        "message": "BrAPI base call found with page=0, pageSize=10"
      },
      {
        "messageType": "INFO",
        "message": "Loading CXGN::BrAPI::v2::ObservationUnits"
      },
      {
        "message": "Observation Units search result constructed",
        "messageType": "INFO"
      }
    ],
    "pagination": {
      "pageSize": 10,
      "totalCount": 1600,
      "totalPages": 160,
      "currentPage": 0
    }
  }
}

This should return a response with one entry per plot and all of the applied management factors as an array in the treatments property.

For Bugs:

Environment

Steps to Reproduce