Skip to content

Commit

Permalink
EPMRPP-92477 set default GA variables (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx authored Jul 10, 2024
1 parent 3b15164 commit e99ab6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class DefectUpdateStatisticsJob extends BaseJob {

private final RestTemplate restTemplate;

private final String measurementId;
private final String mId;
private final String gaId;


Expand All @@ -72,11 +72,11 @@ public class DefectUpdateStatisticsJob extends BaseJob {
*/
@Autowired
public DefectUpdateStatisticsJob(JdbcTemplate jdbcTemplate,
@Value("${rp.environment.variable.ga.measurementId}") String measurementId,
@Value("${rp.environment.variable.ga.mId}") String mId,
@Value("${rp.environment.variable.ga.id}") String gaId,
NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
super(jdbcTemplate);
this.measurementId = measurementId;
this.mId = mId;
this.gaId = gaId;
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
this.restTemplate = new RestTemplate();
Expand All @@ -92,9 +92,9 @@ public DefectUpdateStatisticsJob(JdbcTemplate jdbcTemplate,
@Transactional
public void execute() {
LOGGER.info("Start sending items defect update statistics");
if (StringUtils.isEmpty(measurementId) || StringUtils.isEmpty(gaId)) {
if (StringUtils.isEmpty(mId) || StringUtils.isEmpty(gaId)) {
LOGGER.info(
"Both 'measurementId' and 'gaId' environment variables should be provided in order to run the job 'defectUpdateStatisticsJob'");
"Both 'mId' and 'id' environment variables should be provided in order to run the job 'defectUpdateStatisticsJob'");
return;
}

Expand Down Expand Up @@ -164,9 +164,6 @@ public void execute() {
sendRequest(requestBody);

});

LOGGER.info("Completed items defect update statistics job");

}

private void sendRequest(JSONObject requestBody) {
Expand All @@ -179,7 +176,7 @@ private void sendRequest(JSONObject requestBody) {
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> request = new HttpEntity<>(requestBody.toString(), headers);

String url = String.format(GA_URL, measurementId, gaId);
String url = String.format(GA_URL, mId, gaId);

var response = restTemplate.exchange(url, POST, request, String.class);
if (response.getStatusCodeValue() != 204) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ rp:
## 1 minute
cron: '0 */1 * * * *'
ga:
id:
measurementId:
id: ovxfTlz7QOeaZDPbroXZQA
mId: G-Z22WZS0E4E
cron: '0 0 */24 * * *'
executor:
pool:
Expand Down

0 comments on commit e99ab6e

Please sign in to comment.