Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rematch optimising #308

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
#288 fix rematchLog schema and family(matched) facade removed
  • Loading branch information
qifeng-bai committed Jun 21, 2024
commit 0fc83e8b9ba732a5db786b1808943ba36492e3ba
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import au.org.ala.web.AuthService
//import au.org.ala.names.ws.api.SearchStyle
import com.opencsv.CSVReader
import grails.converters.JSON
import grails.gorm.transactions.NotTransactional
import grails.gorm.transactions.Transactional
import groovy.time.TimeCategory
import org.apache.commons.io.filefilter.FalseFileFilter
Expand Down Expand Up @@ -542,14 +543,17 @@ class SpeciesListController {
}
}


def rematchAll() {
def order = params.order?.equalsIgnoreCase("asc") ? 'asc' : 'desc'
def speciesLists = SpeciesList.list(sort: 'itemsCount', order: order)

def total = speciesLists.size()
def startProcessing = new Date()
def msg = [status: 0, message: "Rematch all species lists [${total}]"]
def msg = [status: 0, message: "Rematch all species lists [${total}], starting with order: ${order}"]

def rematchLog = new RematchLog(byWhom: authService?.userDetails()?.email ?: "Developer", startTime: new Date(), status: 'Running', logs: [msg.message]);
rematchLog.save()

for(int i= 0; i < speciesLists.size(); i++) {
rematchLog.processing = "${i + 1}/${total}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class SpeciesListItemController {

def fqs = requestParams.fq ? [requestParams.fq].flatten().findAll { it != null } : null

def baseQueryAndParams = requestParams.fq ? queryService.constructWithFacets(" from SpeciesListItem sli left join fetch sli.matchedSpecies ", fqs, requestParams.id, requestParams.q) : null
def baseQueryAndParams = requestParams.fq ? queryService.constructWithFacets(" from SpeciesListItem sli ", fqs, requestParams.id, requestParams.q) : null
log.debug(baseQueryAndParams?.toString())

// to sort on a column 'order by' clause has to be added explicitly since executeQuery function does
Expand Down
2 changes: 2 additions & 0 deletions grails-app/domain/au/org/ala/specieslist/RematchLog.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class RematchLog {

static constraints = {
endTime(nullable: true)
latestProcessingTime(nullable: true)
processing(nullable: true)
status(nullable: true)
history(nullable: true)
}
Expand Down
12 changes: 6 additions & 6 deletions grails-app/services/au/org/ala/specieslist/QueryService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,9 @@ class QueryService {
"${q ? 'and (sli.matchedName like :qMatchedName or sli.commonName like :qCommonName or sli.rawScientificName like :qRawScientificName) ' : ''} " +
"group by sli.family order by cnt desc",
queryParameters)
if (commonResults.size() > 1) {
map["family(matched)"] = commonResults
}
// `if (commonResults.size() > 1) {
// map["family_matched"] = commonResults
// }`

//println(results)
properties = results.findAll{ it[1] && it[1]?.length()<maxLengthForFacet }.groupBy { it[0] }.findAll{ it.value.size()>1}
Expand All @@ -932,9 +932,9 @@ class QueryService {
"${q ? 'and (matchedName like :matchedName or commonName like :commonName or rawScientificName like :rawScientificName) ' : ''} " +
'group by family order by cnt desc',
queryParameters)
if(commonResults.size() > 1) {
map["family(matched)"] = commonResults
}
// if(commonResults.size() > 1) {
// map["family_matched"] = commonResults
// }
}
//if there was a facet included in the result we will need to divide the
if(properties) {
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/admin/specieslists.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<a class="btn btn-primary" title="${message(code:'upload.lists.header01', default:'Upload a list')}" href="${request.contextPath}/speciesList/upload">${message(code:'upload.lists.header01', default:'Upload a list')}</a>
<a class="btn btn-primary" title="${message(code:'generic.lists.button.mylist.label', default:'My Lists')}" href="${request.contextPath}/speciesList/list">${message(code:'generic.lists.button.mylist.label', default:'My Lists')}</a>
<g:if test="${rematchLogs.processing}">
<button class="btn btn-primary" onclick="showRematchingProcess('${request.contextPath}/ws/rematchLogs')">Rematching is on process. Click to check status</button>
<a class="btn btn-primary" onclick="showRematchingProcess('${request.contextPath}/ws/rematchLogs')">Check Rematching progress</a>
</g:if>
<g:else>
<a href="#" title="${message(code:'admin.lists.page.button.rematch.tooltip', default:'Rematch')}"
Expand Down