Skip to content

Commit

Permalink
avniproject/avni-webapp#1076 | Limit legacy longitudinal export csv s…
Browse files Browse the repository at this point in the history
…ize to configurable value
  • Loading branch information
Suhas Vishwanath committed Oct 30, 2023
1 parent e782fa0 commit fe98a3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ExportBatchConfiguration {
private final EncounterTypeRepository encounterTypeRepository;
private final ProgramRepository programRepository;
private final int longitudinalExportV2Limit;
private final int legacyLongitudinalExportLimit;

@Autowired
public ExportBatchConfiguration(JobBuilderFactory jobBuilderFactory,
Expand All @@ -65,7 +66,8 @@ public ExportBatchConfiguration(JobBuilderFactory jobBuilderFactory,
EncounterTypeRepository encounterTypeRepository,
ProgramRepository programRepository,
EntityManager entityManager,
@Value("${avni.longitudinal.export.v2.limit}") int longitudinalExportV2Limit
@Value("${avni.longitudinal.export.v2.limit}") int longitudinalExportV2Limit,
@Value("${avni.legacy.longitudinal.export.limit}") int legacyLongitudinalExportLimit
) {
this.jobBuilderFactory = jobBuilderFactory;
this.stepBuilderFactory = stepBuilderFactory;
Expand All @@ -80,6 +82,7 @@ public ExportBatchConfiguration(JobBuilderFactory jobBuilderFactory,
this.programRepository = programRepository;
this.entityManager = entityManager;
this.longitudinalExportV2Limit = longitudinalExportV2Limit;
this.legacyLongitudinalExportLimit = legacyLongitudinalExportLimit;
}

@Bean
Expand Down Expand Up @@ -193,7 +196,8 @@ public Tasklet tasklet(@Value("#{jobParameters['uuid']}") String uuid,
throw new RuntimeException(format("Unknown report type: '%s'", reportType));
}

LongitudinalExportTasklet encounterTasklet = new LongitudinalExportTaskletImpl(CHUNK_SIZE, entityManager, exportCSVFieldExtractor, exportProcessor, exportS3Service, uuid, stream);
Stream alteredStream = stream.limit(this.legacyLongitudinalExportLimit);
LongitudinalExportTasklet encounterTasklet = new LongitudinalExportTaskletImpl(CHUNK_SIZE, entityManager, exportCSVFieldExtractor, exportProcessor, exportS3Service, uuid, alteredStream);
listener.setItemReaderCleaner(encounterTasklet);
return encounterTasklet;
}
Expand Down
1 change: 1 addition & 0 deletions avni-server-api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
avni.custom.query.timeout=${AVNI_CUSTOM_QUERY_TIMEOUT:3}
avni.custom.query.max.rows=${AVNI_CUSTOM_QUERY_MAX_ROWS:2000}
avni.longitudinal.export.v2.limit=${AVNI_LONGITUDINAL_EXPORT_V2_LIMIT:10000}
avni.legacy.longitudinal.export.limit=${AVNI_LEGACY_LONGITUDINAL_EXPORT_LIMIT:10000}

# Hibernate Search
spring.jpa.properties.hibernate.search.default.directory_provider=local-heap
Expand Down
1 change: 1 addition & 0 deletions avni-server-api/src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
avni.custom.query.timeout=${AVNI_CUSTOM_QUERY_TIMEOUT:5}
avni.custom.query.max.rows=${AVNI_CUSTOM_QUERY_MAX_ROWS:2000}
avni.longitudinal.export.v2.limit=${AVNI_LONGITUDINAL_EXPORT_V2_LIMIT:10000}
avni.legacy.longitudinal.export.limit=${AVNI_LEGACY_LONGITUDINAL_EXPORT_LIMIT:10000}
cognito.clientid=dummy
cognito.poolid=dummy
avni.defaultUserName=admin
Expand Down

0 comments on commit fe98a3c

Please sign in to comment.