Skip to content

Commit b414f67

Browse files
committed
Merge branch 'hotfix/wedigbio'
2 parents 1e7cefa + e3d860b commit b414f67

File tree

7 files changed

+84
-35
lines changed

7 files changed

+84
-35
lines changed

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ plugins {
2323
// id "com.moowork.node" version "1.1.1"
2424
}
2525

26-
version "5.2.3"
26+
version "5.2.3.1"
2727
group "au.org.ala"
2828
description "Digivol application"
2929

@@ -164,8 +164,8 @@ dependencies {
164164
compile 'org.grails.plugins:grails-google-visualization:2.2'
165165
compile 'org.grails.plugins:external-config:1.1.2'
166166
// TODO ALA Plugins: image service (is it used anywhere?)
167-
compile 'org.grails.plugins:ala-auth:3.0.3'
168-
compile 'au.org.ala:userdetails-service-client:1.3.0' // override this to for external properties changes
167+
compile 'org.grails.plugins:ala-auth:3.0.4'
168+
compile 'au.org.ala:userdetails-service-client:1.4.0' // override this to for external properties changes
169169
compile 'org.grails.plugins:cache-ehcache:2.0.0.BUILD-SNAPSHOT'
170170
// TODO Collection Event Controller?
171171

@@ -202,7 +202,7 @@ dependencies {
202202
}
203203

204204
bootRun {
205-
jvmArgs('-Dspring.output.ansi.enabled=always', '-Xmx8000m')
205+
jvmArgs('-Dspring.output.ansi.enabled=always', '-Xmx6000m')
206206
// addResources = true // enable for reloading src/main/resources when using gradle bootRun, disables processResources
207207
}
208208

grails-app/controllers/au/org/ala/volunteer/AjaxController.groovy

+27-22
Original file line numberDiff line numberDiff line change
@@ -504,29 +504,34 @@ class AjaxController {
504504
endTs = new Timestamp(System.currentTimeMillis())
505505
}
506506

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
510511

511-
def items = Task.withCriteria {
512+
def items = Transcription.withCriteria {
512513
between('dateFullyTranscribed', startTs, endTs)
513-
join('project')
514+
join('task')
515+
join('task.project')
514516
maxResults(pageSize)
515517
firstResult(rowStart)
516518
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()
525528

526529
transcribers << transcriber
530+
taskIds << taskId
527531
ids << id
528532
[
529533
id: id,
534+
taskId: taskId,
530535
projectId: projectId,
531536
project: projectName,
532537
guid: uuid,
@@ -552,30 +557,30 @@ class AjaxController {
552557
final mm
553558
if (ids) {
554559
allFields = Field.where {
555-
task.id in ids && superceded == false
560+
transcription.id in ids && superceded == false
556561
}.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]
558563
}.groupBy { it.id }
559564
udsw.start()
560-
usersDetails = authService.getUserDetailsById(transcribers, true) ?: [users:[:]]
565+
usersDetails = authService.getUserDetailsById(transcribers.toList(), true) ?: [users:[:]]
561566
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 }
563568
} else {
564569
allFields = [:]
565570
usersDetails = [users:[]]
566571
mm = [:]
567572
}
568573

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
571575

572576
items.each {
573577
def id = it.id
574578
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
576580
def thumbnailUrl = itemMM?.thumbUrl ?: itemMM?.url
577581
def userDetails = usersDetails.users[transcriber]
578582
def displayName = userDetails?.displayName ?: User.findByUserId(transcriber)?.displayName ?: ''
583+
def userCountry = userDetails?.country
579584
def userState = userDetails?.state
580585
def userCity = userDetails?.city
581586
def fields = allFields[id]
@@ -599,8 +604,8 @@ class AjaxController {
599604

600605
if (thumbnailUrl) it.subject.thumbnailUrl = thumbnailUrl
601606
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,
604609
state: userState,
605610
municipality: userCity
606611
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package au.org.ala.volunteer
2+
3+
import au.org.ala.userdetails.UserDetailsFromIdListResponse
4+
import au.org.ala.web.AuthService
5+
import au.org.ala.web.UserDetails
6+
import grails.test.hibernate.HibernateSpec
7+
import grails.test.mixin.TestFor
8+
import org.grails.web.json.JSONArray
9+
import org.grails.web.json.JSONObject
10+
11+
import static au.org.ala.volunteer.helper.TaskDataHelper.setupProject
12+
import static au.org.ala.volunteer.helper.TaskDataHelper.setupTasks
13+
import static au.org.ala.volunteer.helper.TaskDataHelper.transcribe
14+
15+
@TestFor(AjaxController)
16+
class AjaxControllerSpec extends HibernateSpec {
17+
18+
String userId = 'u1'
19+
Project project
20+
List<Task> tasks
21+
22+
void setup() {
23+
project = setupProject()
24+
tasks = setupTasks(project, 10)
25+
tasks.take(5).collect { task -> transcribe(task, userId, [:]) }
26+
controller.authService = Stub(AuthService)
27+
controller.authService.getUserDetailsById(_, _) >> { List<String> ids, boolean includeProps -> new UserDetailsFromIdListResponse(true, '', ['ud1' : new UserDetails(1L, 'First', 'Second', 'ud1@ud1.com', 'ud1', false, '', '', 'organisation', 'Canberra', 'ACT', '', ['ROLE_USER'] as Set)], []) }
28+
}
29+
30+
def "test transcription feed"() {
31+
setup:
32+
33+
when:
34+
controller.transcriptionFeed('','',0,'')
35+
36+
then:
37+
def json = response.json
38+
json instanceof JSONObject
39+
json.numFound == 5
40+
json.items instanceof JSONArray
41+
json.items.size() == 5
42+
}
43+
44+
}

src/test/groovy/au/org/ala/volunteer/AuditServiceSpec.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package au.org.ala.volunteer
33
import grails.test.hibernate.HibernateSpec
44
import grails.test.mixin.TestFor
55

6-
import static au.org.ala.volunteer.au.org.ala.volunteer.helper.TaskDataHelper.*
6+
import static au.org.ala.volunteer.helper.TaskDataHelper.*
77

88
@TestFor(AuditService)
99
class AuditServiceSpec extends HibernateSpec {

src/test/groovy/au/org/ala/volunteer/TaskServiceSpec.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import grails.test.hibernate.HibernateSpec
44
import grails.test.mixin.TestFor
55
import org.grails.orm.hibernate.cfg.Settings
66

7-
import static au.org.ala.volunteer.au.org.ala.volunteer.helper.TaskDataHelper.*
7+
import static au.org.ala.volunteer.helper.TaskDataHelper.*
88

99
@TestFor(TaskService)
1010
class TaskServiceSpec extends HibernateSpec {

src/test/groovy/au/org/ala/volunteer/ValidationServiceSpec.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import grails.test.mixin.Mock
44
import grails.test.mixin.TestFor
55
import spock.lang.Specification
66

7-
import static au.org.ala.volunteer.au.org.ala.volunteer.helper.TaskDataHelper.*
7+
import static au.org.ala.volunteer.helper.TaskDataHelper.*
88

99
/**
1010
* See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions

src/test/groovy/au/org/ala/volunteer/au/org/ala/volunteer/helper/TaskDataHelper.groovy src/test/groovy/au/org/ala/volunteer/helper/TaskDataHelper.groovy

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
package au.org.ala.volunteer.au.org.ala.volunteer.helper
1+
package au.org.ala.volunteer.helper
22

33
import au.org.ala.volunteer.Field
44
import au.org.ala.volunteer.Project
55
import au.org.ala.volunteer.Task
66
import au.org.ala.volunteer.Template
77
import au.org.ala.volunteer.Transcription
88
import au.org.ala.volunteer.ViewedTask
9+
import groovy.util.logging.Slf4j
910

1011

1112
/**
1213
* Helper class for creating Projects, Tasks, Transcriptions, ViewedTasks in the database to assist setting up
1314
* data for testing.
1415
*/
16+
@Slf4j
1517
class TaskDataHelper {
1618

1719
static Project setupProject() {
@@ -31,10 +33,8 @@ class TaskDataHelper {
3133
task
3234
}
3335

34-
static void setupTasks(Project project, int numberOfTasks) {
35-
for (int i=0; i<numberOfTasks; i++) {
36-
addTask(project, i)
37-
}
36+
static List<Task> setupTasks(Project project, int numberOfTasks) {
37+
(0..numberOfTasks).collect { i -> addTask(project, i) }
3838
}
3939

4040
static void transcribe(Task task, String userId, Map<String, String> fields = null) {
@@ -47,7 +47,7 @@ class TaskDataHelper {
4747
task.save(failOnError:true)
4848
}
4949

50-
println "Updating transcription with id="+transcription.id
50+
log.info("Updating transcription with id={}", transcription.id)
5151
transcription.fullyTranscribedBy = userId
5252
transcription.dateFullyTranscribed = new Date()
5353

0 commit comments

Comments
 (0)