APIs & services / commons-report-service

Count farmers across VOs for a Unit In-charge / FMT.

Endpointtoday's app
Call
GET /gateway/commons-report-service/api/v1/datasets/name/PlusOneWorkNodeFarmerListGeoWiseCountUnit/execute
Service
commons-report-service
Features
Data download (Unit / FMT)
When
Data download (Unit In-charge / FMT)
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Counts farmers per VO for a Unit In-charge / FMT. UnitDataSetupViewModel calls it once per VO work node that has no page total yet and stores totalIEPages per VO; SetupForUnitInChargeLogin (the splash path for unit logins) calls it per VO with a 1000-row page size. A failure is recorded for that VO and the rest continue; a count of 0 marks the VO as having nothing to pull.

Headers

HeaderValueNotes
X-SESSIONID<session token>Not set by the call site. AuthInterceptor (OkHttpClientInterceptor) adds it from AndroidSessionManager. On a 401 or 400 it invalidates the token, gets a fresh one and retries once.

Parameters

ParamInRequiredExampleNotes
datasetNamepathYesPlusOneWorkNodeFarmerListGeoWiseCountUnitDataset name in the path of commons-report-service /api/v1/datasets/name/{name}/execute.
versionqueryYes1Dataset version. Always 1.
formatqueryYesjsonResponse format. Always json, so the body is a JSON array of row objects.
paramsqueryYesIN_PARAM_VO_ID_CSV=VO-ALIAS-001Dataset input parameters as KEY=value pairs joined with "--". IN_PARAM_VO_ID_CSV = one VO alias id per call (the name allows CSV, but both callers send one VO at a time).

Request

No body. VO alias list

Response

Example response body (synthetic data)
[
  {
    "TotalFarmer": 845
  }
]
FieldTypeRequiredNotes
TotalFarmerintFarmers in that VO; total pages = ceil(TotalFarmer / page size), saved per VO with Data.repository.updateWorkNodeIESyncProgress.

Errors

StatusWhenWhat the app does
401 / 400Session token expired or rejectedAuthInterceptor refreshes the token and retries once; if the retry also fails, UnitDataSetupViewModel records the error for that VO and moves on; SetupForUnitInChargeLogin calls onError(InvalidResponseException).
5xxDataset query failed on the serverUnitDataSetupViewModel records the error for that VO and moves on; SetupForUnitInChargeLogin calls onError(InvalidResponseException).
network errorNo connectivity or timeoutUnitDataSetupViewModel records the error for that VO and moves on; SetupForUnitInChargeLogin calls onError(InvalidResponseException).
200 with TotalFarmer 0VO has no farmersVO progress set to 0/0 (unit VM) or onError(FarmerCountZero) (splash path).

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup_new/SetupServiceNew.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/UnitDataSetupViewModel.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/setup_new/SetupForUnitInChargeLogin.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/setup_new/IeFlatSchemaCountResponse.kt