Skip to content

Commit

Permalink
Merge pull request #25 from cancogen-virus-seq/rc/0.3.0
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
lepsalex authored Sep 15, 2021
2 parents cf8e6b2 + 3cd0224 commit 784966d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>org.cancogen-virus-seq</groupId>
<artifactId>singularity</artifactId>
<version>0.2.1</version>
<version>0.3.0</version>
<name>singularity</name>
<description>Singularity - All contributors, All files</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.cancogenvirusseq.singularity.components.model.CountAndLastUpdatedResult;
import org.cancogenvirusseq.singularity.repository.ArchivesRepo;
import org.cancogenvirusseq.singularity.repository.model.Archive;
import org.cancogenvirusseq.singularity.repository.model.ArchiveStatus;
import org.cancogenvirusseq.singularity.repository.model.ArchiveType;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -40,12 +38,7 @@ public Mono<ArchiveBuildRequest> apply(Instant instant) {
private Mono<Archive> createAndSaveArchiveToDatabase(
CountAndLastUpdatedResult countAndLastUpdatedResult) {
return archivesRepo.save(
Archive.builder()
.status(ArchiveStatus.BUILDING)
.type(ArchiveType.ALL)
.hashInfo(countAndLastUpdatedResult.getLastUpdatedDate().getValueAsString())
.numOfSamples(countAndLastUpdatedResult.getNumDocuments().getValue())
.build());
Archive.newAllArchiveFromCountAndLastUpdatedResult(countAndLastUpdatedResult));
}

private Function<Archive, ArchiveBuildRequest> transformToArchiveBuildRequest(Instant instant) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.cancogenvirusseq.singularity.components.model;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;

@Getter
@RequiredArgsConstructor
public class AllArchiveHashInfo {
private static final ObjectMapper objectMapper = new ObjectMapper();

private final Long numSamples;
private final String lastUpdated;

public static AllArchiveHashInfo parseFromCountAndLastUpdatedResult(
CountAndLastUpdatedResult countAndLastUpdatedResult) {
return new AllArchiveHashInfo(
countAndLastUpdatedResult.getNumDocuments().getValue(),
countAndLastUpdatedResult.getLastUpdatedDate().getValueAsString());
}

@Override
@SneakyThrows
public String toString() {
return AllArchiveHashInfo.objectMapper.writeValueAsString(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.time.Instant;
import java.util.UUID;
import lombok.*;
import org.cancogenvirusseq.singularity.components.model.AllArchiveHashInfo;
import org.cancogenvirusseq.singularity.components.model.CountAndLastUpdatedResult;
import org.cancogenvirusseq.singularity.components.model.SetQueryArchiveHashInfo;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
Expand Down Expand Up @@ -45,6 +47,18 @@ public String toString() {
}
}

public static Archive newAllArchiveFromCountAndLastUpdatedResult(
CountAndLastUpdatedResult countAndLastUpdatedResult) {
return Archive.builder()
.status(ArchiveStatus.BUILDING)
.type(ArchiveType.ALL)
.hashInfo(
AllArchiveHashInfo.parseFromCountAndLastUpdatedResult(countAndLastUpdatedResult)
.toString())
.numOfSamples(countAndLastUpdatedResult.getNumDocuments().getValue())
.build();
}

public static Archive newFromSetQueryArchiveHashInfo(
SetQueryArchiveHashInfo setQueryArchiveHashInfo) {
return Archive.builder()
Expand All @@ -62,8 +76,9 @@ public static Archive incrementDownloadsForArchive(Archive archive) {

public static String parseFilenameFromArchive(Archive archive) {
if (archive.getType().equals(ArchiveType.ALL)) {
// for a download all entry the hash info is the instant string for the release
return format("virusseq-data-release-%s.tar.gz", archive.getHashInfo());
// for a download all entry, use the createdAt timestamp for the filename
return format(
"virusseq-data-release-%s.tar.gz", Instant.ofEpochSecond(archive.getCreatedAt()));
} else {
// for all other export types just note that it's an export and the download time
return format("virusseq-search-export-%s.tar.gz", Instant.now());
Expand Down

0 comments on commit 784966d

Please sign in to comment.