diff --git a/grails-app/controllers/au/org/ala/profile/ProfileController.groovy b/grails-app/controllers/au/org/ala/profile/ProfileController.groovy index 1fbf7ac..cc4f8eb 100644 --- a/grails-app/controllers/au/org/ala/profile/ProfileController.groovy +++ b/grails-app/controllers/au/org/ala/profile/ProfileController.groovy @@ -3,6 +3,7 @@ package au.org.ala.profile import au.ala.org.ws.security.RequireApiKey import au.ala.org.ws.security.SkipApiKeyCheck import au.org.ala.profile.util.Utils +import com.google.common.base.Stopwatch import grails.converters.JSON import groovy.json.JsonSlurper import org.springframework.http.HttpStatus @@ -437,9 +438,11 @@ class ProfileController extends BaseController { } def getByUuid() { + Stopwatch sw = new Stopwatch().start() log.debug("Fetching profile by profileId ${params.profileId}") Profile profile = getProfile() - + log.trace("Profile db fetched in ${sw}") + sw.reset().start() if (profile) { final fullClassification = params.boolean('fullClassification', false) final latest = params.boolean("latest", false) @@ -447,6 +450,9 @@ class ProfileController extends BaseController { profileService.decorateProfile(profile, latest, true) } + log.trace("Profile decorated in ${sw}") + sw.reset().start() + if (profile && profile.draft && latest) { Opus opus = profile.opus profile = new Profile(profile.draft.properties) @@ -455,10 +461,17 @@ class ProfileController extends BaseController { profile.privateMode = true } + log.trace("Profile darft check ${sw}") + sw.reset().start() + def florulaListId = masterListService.getFlorulaListIdForUser(request, profile.opus.uuid) profile.opus.florulaListId = florulaListId + log.trace("Profile florula check ${sw}") + sw.reset().start() + render (profile as JSON) + log.trace("Profile fetched in ${sw}") } else { notFound() } diff --git a/grails-app/domain/au/org/ala/profile/Opus.groovy b/grails-app/domain/au/org/ala/profile/Opus.groovy index 96b4b7a..4b9a189 100644 --- a/grails-app/domain/au/org/ala/profile/Opus.groovy +++ b/grails-app/domain/au/org/ala/profile/Opus.groovy @@ -135,7 +135,7 @@ class Opus { static mapping = { autoTimestamp true glossary cascade: "all-delete-orphan" - authorities cascade: "all-delete-orphan", fetch: 'join' + authorities cascade: "all-delete-orphan", fetch: 'join', batchSize: 20 shortName index: true uuid index: true additionalOccurrenceResources fetch: 'join' diff --git a/src/main/groovy/au/org/ala/profile/marshaller/OpusMarshaller.groovy b/src/main/groovy/au/org/ala/profile/marshaller/OpusMarshaller.groovy index 07f1fd7..90fc2cc 100644 --- a/src/main/groovy/au/org/ala/profile/marshaller/OpusMarshaller.groovy +++ b/src/main/groovy/au/org/ala/profile/marshaller/OpusMarshaller.groovy @@ -8,12 +8,17 @@ import au.org.ala.profile.Theme import au.org.ala.profile.util.DataResourceOption import au.org.ala.profile.util.ImageOption import au.org.ala.profile.util.ShareRequestStatus +import com.google.common.base.Stopwatch import grails.converters.JSON +import org.slf4j.Logger +import org.slf4j.LoggerFactory -class OpusMarshaller { +class OpusMarshaller { + Logger log = LoggerFactory.getLogger(OpusMarshaller.class) void register() { JSON.registerObjectMarshaller(Opus) { Opus opus -> + Stopwatch sw = new Stopwatch().start() def value = [ uuid : opus.uuid, dataResourceUid : opus.dataResourceUid, @@ -80,6 +85,7 @@ class OpusMarshaller { dateCreated : opus.dateCreated?.time, lastUpdated : opus.lastUpdated?.time ] + log.trace("opusMarshaller() - Get opus by UUID ${opus.uuid}: $sw") return value } } diff --git a/src/main/groovy/au/org/ala/profile/marshaller/ProfileMarshaller.groovy b/src/main/groovy/au/org/ala/profile/marshaller/ProfileMarshaller.groovy index 43fc8f0..d7dc29a 100644 --- a/src/main/groovy/au/org/ala/profile/marshaller/ProfileMarshaller.groovy +++ b/src/main/groovy/au/org/ala/profile/marshaller/ProfileMarshaller.groovy @@ -2,13 +2,17 @@ package au.org.ala.profile.marshaller import au.org.ala.profile.Profile import au.org.ala.profile.util.Utils +import com.google.common.base.Stopwatch import grails.converters.JSON +import org.slf4j.Logger +import org.slf4j.LoggerFactory class ProfileMarshaller { - + Logger log = LoggerFactory.getLogger(ProfileMarshaller.class) void register() { JSON.registerObjectMarshaller(Profile) { Profile profile -> - return [ + Stopwatch sw = new Stopwatch().start() + def value = [ uuid : profile.uuid, guid : profile.guid && profile.guid != "null" ? "${profile.guid}" : "", nslNameIdentifier : profile.nslNameIdentifier, @@ -68,6 +72,9 @@ class ProfileMarshaller { profileStatus : profile.profileStatus, profileSettings : profile.profileSettings? [ autoFormatProfileName: profile.profileSettings.autoFormatProfileName, formattedNameText: profile.profileSettings.formattedNameText ]: null ] + + log.trace("profileMarshaller() - Get profile by UUID ${profile.uuid}: $sw") + return value } } }