Skip to content

Commit eb3da82

Browse files
authored
Merge pull request #1120 from CMSgov/feature/QPPSF-7911_Slow-dynamo
QPPSF-7911: Dynamo Updates
2 parents bd1f549 + 145f323 commit eb3da82

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

commons/src/main/resources/measures-data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5442,8 +5442,8 @@
54425442
"eMeasureUuids": {
54435443
"initialPopulationUuid": "3E177A28-30DE-4381-8C7A-B42CD914DA33",
54445444
"denominatorUuid": "E7E1C3BB-730F-4020-9BF3-3AA508B914FC",
5445-
"numeratorUuid": "827502FD-FF19-45FB-974B-B7F32B281873",
5446-
"denominatorExclusionUuid": "14F9E2DB-C09F-4E06-AFBD-C1E5E178D920"
5445+
"numeratorUuid": "14F9E2DB-C09F-4E06-AFBD-C1E5E178D920",
5446+
"denominatorExclusionUuid": "827502FD-FF19-45FB-974B-B7F32B281873"
54475447
}
54485448
}
54495449
],

rest-api/src/main/java/gov/cms/qpp/conversion/api/services/internal/DbServiceImpl.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,17 @@ public List<Metadata> getUnprocessedCpcPlusMetaData(String orgAttribute) {
8686
Map<String, AttributeValue> valueMap = new HashMap<>();
8787
valueMap.put(":cpcValue", new AttributeValue().withS(Constants.CPC_DYNAMO_PARTITION_START + partition));
8888
valueMap.put(":cpcProcessedValue", new AttributeValue().withS("false#"+year));
89-
valueMap.put(":createDate", new AttributeValue().withS(cpcConversionStartDate));
9089

9190
DynamoDBQueryExpression<Metadata> metadataQuery = new DynamoDBQueryExpression<Metadata>()
9291
.withIndexName(indexName)
9392
.withKeyConditionExpression(Constants.DYNAMO_CPC_ATTRIBUTE + " = :cpcValue and begins_with("
9493
+ orgAttribute + ", :cpcProcessedValue)")
95-
.withFilterExpression(Constants.DYNAMO_CREATE_DATE_ATTRIBUTE + " > :createDate")
9694
.withExpressionAttributeValues(valueMap)
9795
.withConsistentRead(false);
9896

99-
return mapper.get().query(Metadata.class, metadataQuery).stream();
100-
}).flatMap(Function.identity()).collect(Collectors.toList());
97+
return mapper.get().query(Metadata.class, metadataQuery).stream().limit(10);
98+
})
99+
.flatMap(Function.identity()).collect(Collectors.toList());
101100
} else {
102101
API_LOG.warn("Could not get unprocessed CPC+ metadata because the dynamodb mapper is absent");
103102
return Collections.emptyList();
@@ -123,17 +122,15 @@ public List<Metadata> getUnprocessedPcfMetaData(String orgAttribute) {
123122
Map<String, AttributeValue> valueMap = new HashMap<>();
124123
valueMap.put(":pcfValue", new AttributeValue().withS(Constants.PCF_DYNAMO_PARTITION_START + partition));
125124
valueMap.put(":pcfProcessedValue", new AttributeValue().withS("false#"+year));
126-
valueMap.put(":createDate", new AttributeValue().withS(cpcConversionStartDate));
127125

128126
DynamoDBQueryExpression<Metadata> metadataQuery = new DynamoDBQueryExpression<Metadata>()
129127
.withIndexName(indexName)
130128
.withKeyConditionExpression(Constants.DYNAMO_PCF_ATTRIBUTE + " = :pcfValue and begins_with("
131129
+ orgAttribute + ", :pcfProcessedValue)")
132-
.withFilterExpression(Constants.DYNAMO_CREATE_DATE_ATTRIBUTE + " > :createDate")
133130
.withExpressionAttributeValues(valueMap)
134131
.withConsistentRead(false);
135132

136-
return mapper.get().query(Metadata.class, metadataQuery).stream();
133+
return mapper.get().query(Metadata.class, metadataQuery).stream().limit(10);
137134
}).flatMap(Function.identity()).collect(Collectors.toList());
138135
} else {
139136
API_LOG.warn("Could not get unprocessed PCF metadata because the dynamodb mapper is absent");

rest-api/src/test/java/gov/cms/qpp/conversion/api/services/internal/DbServiceImplTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,29 @@ void testNoWriteBecauseNoAudit() {
118118
void testGetUnprocessedCpcPlusMetaData() {
119119
when(environment.getProperty(Constants.CPC_PLUS_UNPROCESSED_FILE_SEARCH_DATE_VARIABLE)).thenReturn("2020-01-01");
120120

121-
int itemsPerPartition = 2;
121+
int itemsPerPartition = 11;
122+
int itemLimitPerpartition = 10;
122123

123124
PaginatedQueryList<Metadata> mockMetadataPage = mock(PaginatedQueryList.class);
124125
Answer<Stream<Metadata>> answer = (InvocationOnMock invocation) -> Stream.generate(Metadata::new).limit(itemsPerPartition);
125-
126+
126127
when(mockMetadataPage.stream()).thenAnswer(answer);
127128
when(dbMapper.query(eq(Metadata.class), any(DynamoDBQueryExpression.class)))
128129
.thenReturn(mockMetadataPage);
129130

130131
List<Metadata> metaDataList = underTest.getUnprocessedCpcPlusMetaData(Constants.CPC_ORG);
131132

132133
verify(dbMapper, times(Constants.CPC_DYNAMO_PARTITIONS)).query(eq(Metadata.class), any(DynamoDBQueryExpression.class));
133-
assertThat(metaDataList).hasSize(itemsPerPartition * Constants.CPC_DYNAMO_PARTITIONS);
134+
assertThat(metaDataList).hasSize(itemLimitPerpartition * Constants.CPC_DYNAMO_PARTITIONS);
134135
}
135136

136137
@Test
137138
@SuppressWarnings("unchecked")
138139
void testGetUnprocessedPcfMetaData() {
139140
when(environment.getProperty(Constants.CPC_PLUS_UNPROCESSED_FILE_SEARCH_DATE_VARIABLE)).thenReturn("2020-01-01");
140141

141-
int itemsPerPartition = 2;
142+
int itemsPerPartition = 11;
143+
int itemLimitPerpartition = 10;
142144

143145
PaginatedQueryList<Metadata> mockMetadataPage = mock(PaginatedQueryList.class);
144146
Answer<Stream<Metadata>> answer = (InvocationOnMock invocation) -> Stream.generate(Metadata::new).limit(itemsPerPartition);
@@ -150,7 +152,7 @@ void testGetUnprocessedPcfMetaData() {
150152
List<Metadata> metaDataList = underTest.getUnprocessedPcfMetaData(Constants.CPC_ORG);
151153

152154
verify(dbMapper, times(Constants.CPC_DYNAMO_PARTITIONS)).query(eq(Metadata.class), any(DynamoDBQueryExpression.class));
153-
assertThat(metaDataList).hasSize(itemsPerPartition * Constants.CPC_DYNAMO_PARTITIONS);
155+
assertThat(metaDataList).hasSize(itemLimitPerpartition * Constants.CPC_DYNAMO_PARTITIONS);
154156
}
155157

156158
@Test

0 commit comments

Comments
 (0)