@@ -504,29 +504,34 @@ class AjaxController {
504
504
endTs = new Timestamp (System . currentTimeMillis())
505
505
}
506
506
507
- final count = Task . countByDateFullyTranscribedBetween(startTs, endTs)
508
- final transcribers = []
509
- final ids = []
507
+ final count = Transcription . countByDateFullyTranscribedBetween(startTs, endTs)
508
+ final transcribers = [] as Set
509
+ final taskIds = [] as Set
510
+ final ids = [] as Set
510
511
511
- def items = Task . withCriteria {
512
+ def items = Transcription . withCriteria {
512
513
between(' dateFullyTranscribed' , startTs, endTs)
513
- join(' project' )
514
+ join(' task' )
515
+ join(' task.project' )
514
516
maxResults(pageSize)
515
517
firstResult(rowStart)
516
518
order(sort, sortOrder)
517
- }. collect { task ->
518
- def id = task. id
519
- def projectId = task. project. id
520
- def projectName = task. project. name
521
- def transcriber = task. fullyTranscribedBy
522
- def timestamp = task. dateFullyTranscribed
523
- def ipAddress = task. fullyTranscribedIpAddress
524
- def uuid = task. transcribedUUID. toString()
519
+ }. collect { Transcription transcription ->
520
+ def id = transcription. id
521
+ def taskId = transcription. task. id
522
+ def projectId = transcription. task. project. id
523
+ def projectName = transcription. task. project. name
524
+ def transcriber = transcription. fullyTranscribedBy
525
+ def timestamp = transcription. dateFullyTranscribed
526
+ def ipAddress = transcription. fullyTranscribedIpAddress
527
+ def uuid = transcription. transcribedUUID. toString()
525
528
526
529
transcribers << transcriber
530
+ taskIds << taskId
527
531
ids << id
528
532
[
529
533
id : id,
534
+ taskId : taskId,
530
535
projectId : projectId,
531
536
project : projectName,
532
537
guid : uuid,
@@ -552,30 +557,30 @@ class AjaxController {
552
557
final mm
553
558
if (ids) {
554
559
allFields = Field . where {
555
- task . id in ids && superceded == false
560
+ transcription . id in ids && superceded == false
556
561
}. collect { field ->
557
- [id : field. taskId , recordIdx : field. recordIdx, name : field. name, value : field. value]
562
+ [id : field. transcriptionId , recordIdx : field. recordIdx, name : field. name, value : field. value]
558
563
}. groupBy { it. id }
559
564
udsw. start()
560
- usersDetails = authService. getUserDetailsById(transcribers, true ) ?: [users :[:]]
565
+ usersDetails = authService. getUserDetailsById(transcribers. toList() , true ) ?: [users :[:]]
561
566
udsw. stop()
562
- mm = Multimedia . where { task. id in ids }. collect { [id : it. taskId, thumbUrl : multimediaService. getImageThumbnailUrl(it), url : multimediaService. getImageUrl(it) ] }. groupBy { it. id }
567
+ mm = Multimedia . where { task. id in taskIds }. collect { [id : it. taskId, thumbUrl : multimediaService. getImageThumbnailUrl(it), url : multimediaService. getImageUrl(it) ] }. groupBy { it. id }
563
568
} else {
564
569
allFields = [:]
565
570
usersDetails = [users :[]]
566
571
mm = [:]
567
572
}
568
573
569
- final invalidState = ' N/A'
570
- final defaultCountry = ' Australia' // we don't record country, so use this if we have a state, todo externalise
574
+ final defaultCountry = ' AU' // TODO externalise
571
575
572
576
items. each {
573
577
def id = it. id
574
578
def transcriber = it. contributor. id
575
- def itemMM = mm[id ] ? mm[id ][0 ] : null
579
+ def itemMM = mm[it . taskId ] ? mm[it . taskId ][0 ] : null
576
580
def thumbnailUrl = itemMM?. thumbUrl ?: itemMM?. url
577
581
def userDetails = usersDetails. users[transcriber]
578
582
def displayName = userDetails?. displayName ?: User . findByUserId(transcriber)?. displayName ?: ' '
583
+ def userCountry = userDetails?. country
579
584
def userState = userDetails?. state
580
585
def userCity = userDetails?. city
581
586
def fields = allFields[id]
@@ -599,8 +604,8 @@ class AjaxController {
599
604
600
605
if (thumbnailUrl) it. subject. thumbnailUrl = thumbnailUrl
601
606
if (displayName) it. contributor. transcriber = displayName
602
- if (userState && userState != invalidState ) it. contributor. physicalLocation = [
603
- country : defaultCountry,
607
+ if (userCity || userState || userCountry ) it. contributor. physicalLocation = [
608
+ country : userCountry ?: defaultCountry,
604
609
state : userState,
605
610
municipality : userCity
606
611
]
0 commit comments