-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1868 statistics with missing counts and datasets missing proprties (#…
…1873) * 1868 statistics with missing counts and datasets missing proprties
- Loading branch information
1 parent
a4998ad
commit c96f779
Showing
13 changed files
with
318 additions
and
34 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...-model/src/main/scala/za/co/absa/enceladus/model/properties/PropertyDefinitionStats.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.enceladus.model.properties | ||
|
||
import za.co.absa.enceladus.model.properties.essentiality.Essentiality | ||
|
||
case class PropertyDefinitionStats(name: String, | ||
version: Int = 1, | ||
essentiality: Essentiality = Essentiality.Optional, | ||
missingInDatasetsCount: Int = 0) | ||
|
||
object PropertyDefinitionStats { | ||
def apply(propertyDefinition: PropertyDefinition, missingCounts: Int): PropertyDefinitionStats = { | ||
PropertyDefinitionStats(propertyDefinition.name, propertyDefinition.version, | ||
propertyDefinition.essentiality, missingCounts) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
menas/src/main/scala/za/co/absa/enceladus/menas/controllers/StatisticsController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.enceladus.menas.controllers | ||
|
||
import java.util.concurrent.CompletableFuture | ||
|
||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.web.bind.annotation.{GetMapping, RequestMapping, RestController} | ||
import za.co.absa.enceladus.menas.services.StatisticsService | ||
import za.co.absa.enceladus.model.properties.PropertyDefinitionStats | ||
|
||
@RestController | ||
@RequestMapping(Array("/api/statistics")) | ||
class StatisticsController @Autowired() (statisticsService: StatisticsService) extends BaseController { | ||
|
||
import za.co.absa.enceladus.menas.utils.implicits._ | ||
|
||
@GetMapping(Array("/properties/missing")) | ||
def getPropertiesWithMissingCount(): CompletableFuture[Seq[PropertyDefinitionStats]] = { | ||
statisticsService.getPropertiesWithMissingCount() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
menas/src/main/scala/za/co/absa/enceladus/menas/services/StatisticsService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.enceladus.menas.services | ||
|
||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Component | ||
import za.co.absa.enceladus.model.properties.{PropertyDefinition, PropertyDefinitionStats} | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
|
||
@Component | ||
class StatisticsService @Autowired() (propertyDefService: PropertyDefinitionService, datasetService: DatasetService){ | ||
//#TODO find optimizations #1897 | ||
def getPropertiesWithMissingCount(): Future[Seq[PropertyDefinitionStats]] = { | ||
val propertyDefsFuture = propertyDefService.getLatestVersions() | ||
propertyDefsFuture | ||
.map { (props: Seq[PropertyDefinition]) => | ||
val propertiesWithMissingCounts: Seq[Future[PropertyDefinitionStats]] = props.map(propertyDef => | ||
datasetService | ||
.getLatestVersions(Some(propertyDef.name)) | ||
.map(datasetsMissingProp => | ||
PropertyDefinitionStats(propertyDef, datasetsMissingProp.size)) | ||
) | ||
propertiesWithMissingCounts | ||
} | ||
.flatMap { propertiesWithMissingCounts: Seq[Future[PropertyDefinitionStats]] => | ||
Future.sequence(propertiesWithMissingCounts) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.