Skip to content

Commit

Permalink
radelt: re-add try/catch on odh sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Jul 22, 2024
1 parent 0d3d801 commit befabc6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.opendatahub.bdp.radelt.dto.organisationen.OrganisationenResponseDto;
import com.opendatahub.bdp.radelt.utils.MappingUtilsAktionen;
import com.opendatahub.bdp.radelt.utils.MappingUtilsOrganisationen;
import org.springframework.web.reactive.function.client.WebClientRequestException;

import it.bz.idm.bdp.dto.DataMapDto;
import it.bz.idm.bdp.dto.RecordDtoImpl;
Expand Down Expand Up @@ -110,13 +111,17 @@ public void syncJob() {
LOG.error("Error fetching challenges: {}", e.getMessage());
}

// Sync with Open Data Hub
odhClientOrganisations.syncStations(stationsOrganisationen);
odhClientChallenges.syncStations(stationsChallenges);
LOG.info("Syncing stations successful");
odhClientOrganisations.pushData(dataOrganisationen);
odhClientChallenges.pushData(dataChallenges);
LOG.info("Pushing data successful");
try {
// Sync with Open Data Hub
odhClientOrganisations.syncStations(stationsOrganisationen);
odhClientChallenges.syncStations(stationsChallenges);
LOG.info("Syncing stations successful");
odhClientOrganisations.pushData(dataOrganisationen);
odhClientChallenges.pushData(dataChallenges);
LOG.info("Pushing data successful");
} catch (WebClientRequestException e) {
LOG.error("Syncing stations failed: Request exception: {}", e.getMessage());
}

LOG.info("Cron job completed successfully");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import it.bz.idm.bdp.dto.DataTypeDto;
import it.bz.idm.bdp.json.NonBlockingJSONPusher;
import org.springframework.web.reactive.function.client.WebClientRequestException;

public class DataTypeUtils {

Expand All @@ -22,96 +23,100 @@ public static void setupDataType(NonBlockingJSONPusher odhClient) {

odhDataTypeList.add(
new DataTypeDto(
"km_total",
"km",
"Total amount of kilometers registered",
"total"));
"km_total",
"km",
"Total amount of kilometers registered",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"height_meters_total",
"meters",
"Total amount of height meters registered",
"total"));
"height_meters_total",
"meters",
"Total amount of height meters registered",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"km_average",
"km",
"Average number of kilometers registered",
"average"));
"km_average",
"km",
"Average number of kilometers registered",
"average"));

odhDataTypeList.add(
new DataTypeDto(
"kcal",
"kcal",
"Total amount of kilocalories registered",
"total"));
"kcal",
"kcal",
"Total amount of kilocalories registered",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"co2",
"kg",
"Total amount of CO2 emissions savings",
"total"));
"co2",
"kg",
"Total amount of CO2 emissions savings",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"m2_trees",
"m2",
"Total equivalent tree area created with CO2 savings",
"total"));
"m2_trees",
"m2",
"Total equivalent tree area created with CO2 savings",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"money_saved",
"EUR",
"Total amount of money saved",
"total"));
"money_saved",
"EUR",
"Total amount of money saved",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"number_of_people",
"count",
"Total number of registered users",
"total"));
"number_of_people",
"count",
"Total number of registered users",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"workplace_count",
"count",
"Total number of people at workplace",
"total"));
"workplace_count",
"count",
"Total number of people at workplace",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"university_count",
"count",
"Total number of people at University",
"total"));
"university_count",
"count",
"Total number of people at University",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"school_count",
"count",
"Total number of people at school",
"total"));
"school_count",
"count",
"Total number of people at school",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"organisation_count",
"count",
"Total number of people at organisation",
"total"));
"organisation_count",
"count",
"Total number of people at organisation",
"total"));

odhDataTypeList.add(
new DataTypeDto(
"municipality_count",
"count",
"Total number of municipalities",
"total"));

odhClient.syncDataTypes(odhDataTypeList);
LOG.info("Sync data type completed successfully");
"municipality_count",
"count",
"Total number of municipalities",
"total"));

try {
odhClient.syncDataTypes(odhDataTypeList);
LOG.info("Sync data type completed successfully");
} catch (WebClientRequestException e) {
LOG.error("Syncing stations failed: Request exception: {}", e.getMessage());
}
}
}

0 comments on commit befabc6

Please sign in to comment.