Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
gs-gunjan committed Oct 30, 2023
2 parents acee639 + 9e8f004 commit ea319b7
Show file tree
Hide file tree
Showing 52 changed files with 172 additions and 112 deletions.
2 changes: 1 addition & 1 deletion legend-depot-artifacts-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-repository-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-repository-maven-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-authorisation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-data-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface ProjectsService
{
List<StoreProjectData> getAllProjectCoordinates();

List<StoreProjectVersionData> findByUpdatedDate(long updatedFrom, long updatedTo);

default List<String> getVersions(String groupId, String artifactId)
{
return getVersions(groupId, artifactId,false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface ProjectsVersions
{
List<StoreProjectVersionData> getAll();

List<StoreProjectVersionData> findByUpdatedDate(long updatedFrom, long updatedTo);

List<StoreProjectVersionData> find(String groupId, String artifactId);

Optional<StoreProjectVersionData> find(String groupId, String artifactId, String versionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ public class StoreProjectVersionData extends VersionedData implements HasIdentif
private boolean evicted = false;
@JsonProperty
private Date creationDate;
//TODO: understand how to populate last updated
@JsonProperty
private Date lastUpdated;
private Date updated;
@JsonProperty
private ProjectVersionData versionData = new ProjectVersionData();
@JsonProperty
Expand Down Expand Up @@ -71,16 +70,6 @@ public void setCreationDate(Date creationDate)
this.creationDate = creationDate;
}

public Date getLastUpdated()
{
return lastUpdated;
}

public void setLastUpdated(Date lastUpdated)
{
this.lastUpdated = lastUpdated;
}

public boolean isEvicted()
{
return evicted;
Expand Down Expand Up @@ -111,6 +100,11 @@ public void setTransitiveDependenciesReport(VersionDependencyReport transitiveDe
this.transitiveDependenciesReport = transitiveDependenciesReport;
}

public Date getUpdated()
{
return updated;
}

@Override
@JsonIgnore
public String getId()
Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-data-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import org.finos.legend.depot.core.services.tracing.resources.TracingResource;
import org.finos.legend.depot.core.services.api.metrics.PrometheusMetricsHandler;
import org.finos.legend.depot.server.resources.projects.ProjectsResource;
import org.finos.legend.depot.server.resources.versions.ProjectsVersionsResource;
import org.finos.legend.depot.server.resources.dependencies.DependenciesResource;
Expand All @@ -38,4 +37,14 @@ protected void configure()
expose(ProjectsVersionsResource.class);
expose(DependenciesResource.class);
}

@Singleton
@Provides
boolean registerResourceMetrics(PrometheusMetricsHandler metricsHandler)
{
metricsHandler.registerResourceSummaries(ProjectsResource.class);
metricsHandler.registerResourceSummaries(ProjectsVersionsResource.class);
metricsHandler.registerResourceSummaries(DependenciesResource.class);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import static org.finos.legend.depot.domain.DatesHandler.toTime;

@Path("")
@Api("Versions")
public class ProjectsVersionsResource extends TracingResource
Expand All @@ -54,6 +59,18 @@ public ProjectsVersionsResource(ProjectsService projectVersionApi)
this.projectVersionApi = projectVersionApi;
}


@GET
@Path("/projects/versions/{updatedFrom}")
@ApiOperation(ResourceLoggingAndTracing.GET_VERSIONS_BY_LASTUPDATE_DATE)
@Produces(MediaType.APPLICATION_JSON)
public List<StoreProjectVersionData> findByUpdatedDate(@PathParam("updatedFrom") @ApiParam(value = "Updated From Date value in milliseconds (UTC) ") long updatedFrom,
@QueryParam("updatedTo") @ApiParam(value = "Updated To Date value in milliseconds (UTC) ") Long updatedTo)
{
return handle(ResourceLoggingAndTracing.GET_VERSIONS_BY_LASTUPDATE_DATE,
() -> projectVersionApi.findByUpdatedDate(updatedFrom, updatedTo == null ? toTime(LocalDateTime.now()) : updatedTo));
}

@GET
@Path("/versions/{groupId}/{artifactId}/{versionId}")
@ApiOperation(value = ResourceLoggingAndTracing.GET_PROJECT_VERSION_BY_GAV, response = ProjectVersionDTO.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public List<StoreProjectData> findByProjectId(String projectId)
return projects.findByProjectId(projectId);
}

@Override
public List<StoreProjectVersionData> findByUpdatedDate(long updatedFrom, long updatedTo)
{
return projectsVersions.findByUpdatedDate(updatedFrom, updatedTo);
}

@Override
public List<StoreProjectVersionData> find(String groupId, String artifactId)
{
Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-data-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
import java.util.Optional;

import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.gte;
import static com.mongodb.client.model.Filters.lt;

public class ProjectsVersionsMongo extends BaseMongo<StoreProjectVersionData> implements ProjectsVersions, UpdateProjectsVersions
{
Expand All @@ -60,6 +61,21 @@ public List<StoreProjectVersionData> getAll()
return getAllStoredEntities();
}

/** Return the list of all stored entities which have been updated from the given
* timestamp or beyond.
* Records with updated time matching the given input will also be returned.
*
* @param updatedFrom - the updated from timestamp in milliseconds (UTC) (inclusive)
* @param updatedTo - the updated to timestamp in milliseconds (UTC) (exclusive)
* @return - list of all stored entities which have been updated from and beyond the given updated from time till
* the given updated to time
*/
@Override
public List<StoreProjectVersionData> findByUpdatedDate(long updatedFrom, long updatedTo)
{
return find(and(gte(UPDATED, updatedFrom),(lt(UPDATED, updatedTo))));
}

@Override
public List<StoreProjectVersionData> find(String groupId, String artifactId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import org.junit.Before;
import org.junit.Test;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import static org.finos.legend.depot.domain.DatesHandler.toTime;


public class TestQueryProjectVersionApi extends CoreDataMongoStoreTests
{
Expand All @@ -44,6 +47,23 @@ public void canCollectAllProjectConfig()
Assert.assertEquals(6, allConfigs.size());
}

@Test
public void canCollectAllProjectConfigUpdatedFrom()
{
List<StoreProjectVersionData> allConfigs = projectsVersionsAPI.findByUpdatedDate(1687227600000L,
toTime(LocalDateTime.now()));
Assert.assertNotNull(allConfigs);
Assert.assertEquals(3, allConfigs.size());
}

@Test
public void canCollectAllProjectConfigUpdatedFromTo()
{
List<StoreProjectVersionData> allConfigs = projectsVersionsAPI.findByUpdatedDate(1687219200000L, 1687219210000L);
Assert.assertNotNull(allConfigs);
Assert.assertEquals(1, allConfigs.size());
}

@Test
public void testFindingByProjectVersionCoordinates()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
{
"groupId": "examples.metadata",
"artifactId": "test",
"versionId": "2.2.0"
"versionId": "2.2.0",
"updated": "2023-04-20"
},
{
"groupId": "examples.metadata",
"artifactId": "test",
"versionId": "master-SNAPSHOT",
"updated": "2023-05-20",
"versionData": {
"dependencies": [
{
Expand All @@ -22,6 +24,7 @@
"groupId": "examples.metadata",
"artifactId": "test",
"versionId": "3.0.0",
"updated": "2023-06-20",
"versionData": {
"excluded": "true",
"exclusionReason": "version could not be loaded"
Expand All @@ -31,6 +34,7 @@
"groupId": "examples.metadata",
"artifactId": "test",
"versionId": "2.3.1",
"updated": "2023-09-20",
"versionData": {
"dependencies": [
{
Expand All @@ -48,11 +52,14 @@
{
"groupId": "examples.metadata",
"artifactId": "test-dependencies",
"versionId": "1.0.0"
"versionId": "1.0.0",
"updated": "2023-07-20"

},
{
"groupId": "example.services.test",
"artifactId": "test",
"versionId": "2.0.1"
"versionId": "2.0.1",
"updated": "2023-08-20"
}
]
2 changes: 1 addition & 1 deletion legend-depot-core-schedules-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
18 changes: 1 addition & 17 deletions legend-depot-core-schedules-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -65,20 +65,4 @@


</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
2 changes: 1 addition & 1 deletion legend-depot-core-schedules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-store-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.10.1-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit ea319b7

Please sign in to comment.