Skip to content

Commit

Permalink
add new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
BBesrour committed Sep 29, 2024
1 parent c727cd7 commit e045310
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ public class Telemetry extends DomainObject {
@Column(name = "contact")
private String contact;

@Column(name = "is_production_instance")
private boolean isProductionInstance;

@Column(name = "datasource")
private String dataSource;

@Column(name = "number_of_nodes")
private int numberOfNodes;

@Column(name = "build_agent_count")
private int buildAgentCount;

public String getProfiles() {
return profiles;
}
Expand Down Expand Up @@ -86,4 +98,36 @@ public String getContact() {
public void setContact(String contact) {
this.contact = contact;
}

public boolean isProductionInstance() {
return isProductionInstance;
}

public void setProductionInstance(boolean productionInstance) {
isProductionInstance = productionInstance;
}

public int getNumberOfNodes() {
return numberOfNodes;
}

public void setNumberOfNodes(int numberOfNodes) {
this.numberOfNodes = numberOfNodes;
}

public String getDataSource() {
return dataSource;
}

public void setDataSource(String dataSource) {
this.dataSource = dataSource;
}

public int getBuildAgentCount() {
return buildAgentCount;
}

public void setBuildAgentCount(int buildAgentCount) {
this.buildAgentCount = buildAgentCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record TelemetryDTO(Long id, String version, String serverUrl, String operator, String adminName, List<String> profiles, String contact, ZonedDateTime timestamp) {
public record TelemetryDTO(Long id, String version, String serverUrl, String operator, String adminName, List<String> profiles, String contact, ZonedDateTime timestamp,
boolean isProductionInstance, String dataSource, int numberOfNodes, int buildAgentCount) {

public static TelemetryDTO from(Telemetry telemetry) {
List<String> profilesList = List.of(telemetry.getProfiles().split(","));
return new TelemetryDTO(telemetry.getId(), telemetry.getVersion(), telemetry.getServerUrl(), telemetry.getOperatorName(), telemetry.getAdminName(), profilesList, telemetry.getContact(), telemetry.getTimestamp());
return new TelemetryDTO(telemetry.getId(), telemetry.getVersion(), telemetry.getServerUrl(), telemetry.getOperatorName(), telemetry.getAdminName(), profilesList, telemetry.getContact(), telemetry.getTimestamp(),
telemetry.isProductionInstance(), telemetry.getDataSource(), telemetry.getNumberOfNodes(), telemetry.getBuildAgentCount());
}

public static Telemetry to(TelemetryDTO telemetryDTO) {
Expand All @@ -25,6 +27,10 @@ public static Telemetry to(TelemetryDTO telemetryDTO) {
telemetry.setProfiles(profiles);
telemetry.setTimestamp(telemetryDTO.timestamp());
telemetry.setContact(telemetryDTO.contact());
telemetry.setProductionInstance(telemetryDTO.isProductionInstance());
telemetry.setDataSource(telemetryDTO.dataSource());
telemetry.setNumberOfNodes(telemetryDTO.numberOfNodes());
telemetry.setBuildAgentCount(telemetryDTO.buildAgentCount());
return telemetry;
}
}
13 changes: 13 additions & 0 deletions src/main/resources/db/changelog/20240929130000.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet id="20240929130000_1" author="bbesrour">
<addColumn tableName="telemetry">
<column name="is_production_instance" type="boolean" defaultValue="false"/>
<column name="datasource" type="longtext"/>
<column name="number_of_nodes" type="int" defaultValue="0"/>
<column name="build_agent_count" type="int" defaultValue="0"/>
</addColumn>
</changeSet>
</databaseChangeLog>
2 changes: 1 addition & 1 deletion src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

<!-- Reference changesets here -->
<include file="classpath:db/changelog/initial-schema.xml"/>
<!-- <include file="classpath:db/changelog/20240929130000.xml"/>-->
<include file="classpath:db/changelog/20240929130000.xml"/>
</databaseChangeLog>

0 comments on commit e045310

Please sign in to comment.