Skip to content

Commit 84c582a

Browse files
- ADD: Added trial stats endpoint for anonymised trial duration data.
- ADD: Added treatment field to cells. -
1 parent 1a59f54 commit 84c582a

7 files changed

Lines changed: 101 additions & 12 deletions

File tree

.idea/workspace.xml

Lines changed: 38 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/jhi/gridscore/server/pojo/Cell.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Cell
1717
private String barcode;
1818
private String friendlyName;
1919
private String pedigree;
20+
private String treatment;
2021
private String rep;
2122
private Boolean isMarked;
2223
private Geography geography;
@@ -31,6 +32,7 @@ public Cell(Cell input)
3132
this.barcode = input.getBarcode();
3233
this.friendlyName = input.getFriendlyName();
3334
this.pedigree = input.getPedigree();
35+
this.treatment = input.getTreatment();
3436
this.rep = input.getRep();
3537
this.isMarked = input.getIsMarked();
3638
this.geography = input.getGeography();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package jhi.gridscore.server.pojo;
2+
3+
import lombok.*;
4+
import lombok.experimental.Accessors;
5+
6+
@Getter
7+
@Setter
8+
@Accessors(chain = true)
9+
@NoArgsConstructor
10+
@ToString
11+
public class TrialStats
12+
{
13+
private String createdOn;
14+
private String updatedOn;
15+
private Integer duration;
16+
}

src/main/java/jhi/gridscore/server/pojo/transaction/PlotDetailContent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ public class PlotDetailContent extends PlotContent
1313
private String pedigree;
1414
private String friendlyName;
1515
private String barcode;
16+
private String treatment;
1617
}

src/main/java/jhi/gridscore/server/resource/TrialResource.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.logicsquad.nanocaptcha.image.backgrounds.FlatColorBackgroundProducer;
1313
import org.apache.commons.collections4.CollectionUtils;
1414
import org.jooq.*;
15+
import org.jooq.impl.*;
1516
import org.jooq.tools.StringUtils;
1617

1718
import javax.imageio.ImageIO;
@@ -453,4 +454,29 @@ public Response getRenewCaptcha(@PathParam("shareCode") String shareCode)
453454
.build();
454455
}
455456
}
457+
458+
@GET
459+
@Path("/stats")
460+
@Consumes(MediaType.APPLICATION_JSON)
461+
@Produces(MediaType.APPLICATION_JSON)
462+
public Response getTrialOverviewstats()
463+
throws SQLException
464+
{
465+
try (Connection conn = Database.getConnection())
466+
{
467+
DSLContext context = Database.getContext(conn);
468+
469+
Field<Integer> duration = DSL.dateDiff(DSL.cast(TRIALS.UPDATED_ON, SQLDataType.DATE), DSL.cast(TRIALS.CREATED_ON, SQLDataType.DATE)).as("duration");
470+
471+
return Response.ok(context.select(
472+
DSL.cast(TRIALS.CREATED_ON, SQLDataType.DATE).as("created_on"),
473+
DSL.cast(TRIALS.UPDATED_ON, SQLDataType.DATE).as("updated_on"),
474+
duration
475+
).from(TRIALS)
476+
.having(duration.ge(10))
477+
.orderBy(TRIALS.UPDATED_ON.desc(), duration.desc())
478+
.fetchInto(TrialStats.class)
479+
).build();
480+
}
481+
}
456482
}

src/main/java/jhi/gridscore/server/resource/TrialTransactionResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ else if (Objects.equals(shareCode, wrapper.getEditorCode()))
246246
{
247247
cell.setBarcode(plotChanges.getBarcode())
248248
.setFriendlyName(plotChanges.getFriendlyName())
249-
.setPedigree(plotChanges.getPedigree());
249+
.setPedigree(plotChanges.getPedigree())
250+
.setTreatment(plotChanges.getTreatment());
250251
}
251252
}
252253

src/main/java/jhi/gridscore/server/util/DataToSpreadsheet.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ private void exportIndividually(XSSFSheet data, XSSFSheet dates)
306306
dc.setCellValue(columnLabel);
307307
pc.setCellValue(columnLabel);
308308

309+
// Write the treatment (if available)
310+
dc = getCell(d, 5);
311+
pc = getCell(p, 5);
312+
if (!StringUtils.isEmpty(cell.getTreatment())) {
313+
dc.setCellValue(cell.getTreatment());
314+
pc.setCellValue(cell.getTreatment());
315+
}
316+
309317
// Write the location
310318
if (cell.getGeography() != null)
311319
{
@@ -514,6 +522,14 @@ private void exportAggregatedPerDay(XSSFSheet data, XSSFSheet dates)
514522
dc.setCellValue(columnLabel);
515523
pc.setCellValue(columnLabel);
516524

525+
// Write the treatment (if available)
526+
dc = getCell(d, 5);
527+
pc = getCell(p, 5);
528+
if (!StringUtils.isEmpty(c.getTreatment())) {
529+
dc.setCellValue(c.getTreatment());
530+
pc.setCellValue(c.getTreatment());
531+
}
532+
517533
// Write the location
518534
if (c.getGeography() != null)
519535
{

0 commit comments

Comments
 (0)