Skip to content

Commit

Permalink
Merge branch 'release/1.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
sbearcsiro committed Jun 3, 2021
2 parents 37aac70 + f286ea2 commit 9b56cde
Show file tree
Hide file tree
Showing 19 changed files with 202 additions and 104 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}


version "1.1.2"
version "1.1.3"

group "au.org.ala"

Expand Down
12 changes: 6 additions & 6 deletions grails-app/conf/logback.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,21 @@ final warn = [
'grails.plugins.mail',
'org.hibernate',
'org.quartz',
'org.flywaydb',
'asset.pipeline'
]
final info = [
'org.flywaydb',
'au.org.ala.images'
]

final debug = []
final trace = []

for (def name : error) logger(name, ERROR, ['STDOUT'])
for (def name : warn) logger(name, WARN, ['STDOUT'])
for (def name: info) logger(name, INFO, ['STDOUT'])
for (def name: debug) logger(name, DEBUG, ['STDOUT'])
for (def name: trace) logger(name, TRACE, ['STDOUT'])
for (def name : error) logger(name, ERROR)
for (def name : warn) logger(name, WARN)
for (def name: info) logger(name, INFO)
for (def name: debug) logger(name, DEBUG)
for (def name: trace) logger(name, TRACE)

logger('au.org.ala.images.CodeTimer', INFO, ['TIMING_LOG'], false)
logger('au.org.ala.images.ScheduleReindexAllImagesTask', INFO, ['INDEXING_LOG'], false)
Expand Down
9 changes: 7 additions & 2 deletions grails-app/conf/spring/resources.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.flywaydb.core.Flyway
import org.postgresql.ds.PGSimpleDataSource
import org.springframework.beans.factory.config.BeanDefinition

// Place your Spring DSL code here
Expand All @@ -7,7 +8,12 @@ beans = {

flyway(Flyway) { bean ->
bean.initMethod = 'migrate'
dataSource = ref('dataSource')
dataSource = { PGSimpleDataSource pgds ->
url = application.config.flyway.jdbcUrl ?: application.config.dataSource.url
user = application.config.flyway.username ?: application.config.dataSource.username
password = application.config.flyway.password ?: application.config.dataSource.password
}

baselineOnMigrate = application.config.getProperty('flyway.baselineOnMigrate', Boolean, true)
def outOfOrderProp = application.config.getProperty('flyway.outOfOrder', Boolean, false)
outOfOrder = outOfOrderProp
Expand All @@ -30,7 +36,6 @@ beans = {
if (hibernateDatastoreBeanDef) {
addDependency(hibernateDatastoreBeanDef, 'flyway')
}

}
else {
log.info "Grails Flyway plugin has been disabled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@ class StorageLocationController {

def listFragment() {
def storageLocationList = StorageLocation.list([sort: 'id'])
def imageCounts = storageLocationList.collectEntries {
[(it.id): Image.countByStorageLocationAndDateDeletedIsNull(it) ]
}
def verifieds = storageLocationList.collectEntries {
[ (it.id): it.verifySettings() ]
}
[storageLocationList: storageLocationList, imageCounts: imageCounts, defaultId: settingService.getStorageLocationDefault(), verifieds: verifieds]
[storageLocationList: storageLocationList, defaultId: settingService.getStorageLocationDefault(), verifieds: verifieds]
}

def editFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package au.org.ala.images
import au.ala.org.ws.security.RequireApiKey
import au.org.ala.cas.util.AuthenticationUtils
import au.org.ala.ws.security.ApiKeyInterceptor
import com.google.common.base.Suppliers
import grails.converters.JSON
import grails.converters.XML
import io.swagger.annotations.Api
Expand All @@ -21,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile
import swagger.SwaggerService

import javax.servlet.http.HttpServletRequest
import java.util.concurrent.TimeUnit
import java.util.zip.GZIPOutputStream

@Api(value = "/ws", description = "Image Web Services")
Expand Down Expand Up @@ -666,12 +668,19 @@ class WebServiceController {
@ApiResponse(code = 404, message = "Image Not Found")]
)
def getRepositoryStatistics() {
def results = statsCache.get()
renderResults(results, 200, true)
}

private def statsCache = Suppliers.memoizeWithExpiration(this.&getRepositoryStatisticsResultsInternal, 1, TimeUnit.MINUTES)

private Map<String, Integer> getRepositoryStatisticsResultsInternal() {
def results = [:]
results.imageCount = Image.count()
results.deletedImageCount = Image.countByDateDeletedIsNotNull()
results.licenceCount = License.count()
results.licenceMappingCount = LicenseMapping.count()
renderResults(results, 200, true)
return results
}

@ApiOperation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package image.service
package au.org.ala.images

import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package image.service
package au.org.ala.images

class BootStrap {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ class ElasticSearchService {
ct.stop(true)

ct = new CodeTimer("Object retrieval (${searchResponse.hits.hits.length} of ${searchResponse.hits.totalHits} hits)")
final imageList = searchResponse.hits ? Image.findAllByImageIdentifierInList(searchResponse.hits*.id)?.collect { image ->
final hitsIdList = searchResponse.hits ? searchResponse.hits*.id : []
final imageList = hitsIdList ? Image.findAllByImageIdentifierInList(hitsIdList)?.collect { image ->
image.metadata = null
image.tags = null
asMap(image)
Expand Down
Loading

0 comments on commit 9b56cde

Please sign in to comment.