Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- updated opus domain object to load faster
- added more debugging statements
  • Loading branch information
temi committed Jul 30, 2024
1 parent e4b3f53 commit 5c97208
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -437,16 +438,21 @@ 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)
if (fullClassification) {
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)
Expand All @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion grails-app/domain/au/org/ala/profile/Opus.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
}
}

0 comments on commit 5c97208

Please sign in to comment.