Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/hellodata 1118 wrong timezone in announcements #7

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class LocalDateTimeToMillisSerializer extends JsonSerializer<LocalDateTime> {

@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeNumber(value.toEpochSecond(ZoneOffset.UTC) * 1000L);
log.debug("Serializing date {}", value);
ZonedDateTime zdt = ZonedDateTime.of(value, ZoneId.systemDefault());
gen.writeNumber(zdt.toInstant().toEpochMilli());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import ch.bedag.dap.hellodata.portal.superset.data.UpdateSupersetDashboardMetadataDto;
import ch.bedag.dap.hellodata.portal.superset.entity.DashboardMetadataEntity;
import ch.bedag.dap.hellodata.portal.superset.repository.DashboardMetadataRepository;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -146,7 +148,8 @@ private void fetchMetadata(String instanceName, SupersetDashboard dashboard, Sup
dashboardDto.setScheduled(dashboardMetadataEntity.getScheduled());
dashboardDto.setDatasource(dashboardMetadataEntity.getDatasource());
LocalDateTime lastAccessDate = dashboardMetadataEntity.getModifiedDate() != null ? dashboardMetadataEntity.getModifiedDate() : dashboardMetadataEntity.getCreatedDate();
long metadataModifiedBy = lastAccessDate.toInstant(ZoneOffset.UTC).toEpochMilli();
ZonedDateTime zdt = ZonedDateTime.of(lastAccessDate, ZoneId.systemDefault());
long metadataModifiedBy =zdt.toInstant().toEpochMilli();
dashboardDto.setModified(Math.max(changedOnUtcInSuperset, metadataModifiedBy));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void toSimpleMailMessage_when_user_deactivated_should_generate_correct_ht
Document actualDoc = Jsoup.parse(Objects.requireNonNull(email.getText()));

//then
assertThat(expectedDoc.html()).isEqualTo(actualDoc.html());
assertThat(actualDoc.html()).isEqualTo(expectedDoc.html());
}

@Test
Expand Down Expand Up @@ -115,7 +115,7 @@ public void toSimpleMailMessage_when_user_activated_should_generate_correct_html
Document actualDoc = Jsoup.parse(Objects.requireNonNull(email.getText()));

//then
assertThat(expectedDoc.html()).isEqualTo(actualDoc.html());
assertThat(actualDoc.html()).isEqualTo(expectedDoc.html());
}

@Test
Expand Down Expand Up @@ -162,7 +162,7 @@ public void toSimpleMailMessage_when_user_role_changed_should_generate_correct_h
Document actualDoc = Jsoup.parse(Objects.requireNonNull(email.getText()));

//then
assertThat(expectedDoc.html()).isEqualTo(actualDoc.html());
assertThat(actualDoc.html()).isEqualTo(expectedDoc.html());
}

@Test
Expand Down Expand Up @@ -210,6 +210,6 @@ public void toSimpleMailMessage_when_user_account_created_should_generate_correc
Document actualDoc = Jsoup.parse(Objects.requireNonNull(email.getText()));

//then
assertThat(expectedDoc.html()).isEqualTo(actualDoc.html());
assertThat(actualDoc.html()).isEqualTo(expectedDoc.html());
}
}