Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Conversation

@vitaxa
Copy link
Contributor

@vitaxa vitaxa commented Oct 18, 2022

add exchange rate listener

bump service parent pom

bump service parent pom
@vitaxa vitaxa requested a review from a team as a code owner October 18, 2022 11:33
exrate:
id: etl-exchange-rate
enabled: false
consumer.group-id: "newway-exrate"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут они не будут конфликтовать с newway?

Comment on lines +47 to +48
"kafka.topics.limit-config.id",
"kafka.topics.limit-config.id",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дубль

Comment on lines 1 to 13
CREATE TABLE dw.exrate
(
id BIGSERIAL NOT NULL,
event_id uuid UNIQUE NOT NULL,
event_created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
source_currency_symbolic_code CHARACTER VARYING NOT NULL,
source_currency_exponent SMALLINT NOT NULL,
destination_currency_symbolic_code CHARACTER VARYING NOT NULL,
destination_currency_exponent SMALLINT NOT NULL,
rational_p BIGINT NOT NULL,
rational_q BIGINT NOT NULL,
rate_timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не должно быть ex_rate? Это же от exchange_rate?
Сущность создается Exrate, хотя имхо должна быть ExRate.

Copy link

@mr-impossibru mr-impossibru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не увидел тест на новое Dao, но не критично


public interface ExchangeRateHandler {

void handle(CurrencyEvent currencyEvent);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не хочешь сделать тут сохранение пачки?
Обычно по возможности сразу набор сущностей в БД сохраняем.

.map(exrate -> getDslContext().newRecord(EX_RATE, exrate))
.map(record -> (Query) getDslContext().insertInto(EX_RATE).set(record)
.onConflict(EX_RATE.EVENT_ID)
.doNothing()).collect(Collectors.toList());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

форматирование

.doNothing())
.collect(Collectors.toList());

Copy link
Contributor Author

@vitaxa vitaxa Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  Надо взять за правило, если линтер не тригерится, значит не считается) Но я поправлю

Comment on lines +26 to +37
CurrencyExchangeRate exchangeRate = currencyEvent.getPayload().getExchangeRate();
ExRate exrate = new ExRate();
exrate.setEventId(UUID.fromString(currencyEvent.getEventId()));
exrate.setEventCreatedAt(TypeUtil.stringToLocalDateTime(currencyEvent.getEventCreatedAt()));
exrate.setSourceCurrencySymbolicCode(exchangeRate.getSourceCurrency().getSymbolicCode());
exrate.setSourceCurrencyExponent(exchangeRate.getSourceCurrency().getExponent());
exrate.setDestinationCurrencySymbolicCode(exchangeRate.getDestinationCurrency().getSymbolicCode());
exrate.setDestinationCurrencyExponent(exchangeRate.getDestinationCurrency().getExponent());
exrate.setRationalP(exchangeRate.getExchangeRate().getP());
exrate.setRationalQ(exchangeRate.getExchangeRate().getQ());
exrate.setRateTimestamp(TypeUtil.stringToLocalDateTime(exchangeRate.timestamp));
return exrate;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опционально, не хочешь вынести в конвертер или отдельный метод внутри handler'а?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nononononono

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По-хорошему, тут везде надо рефакторить и заводить конвертеры. Ну короч хз, читабельнее щас от этого не станет. Если очень хочешь, тогда сделаю конечно.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, у меня были сомнения и я решил тебе о них сказать :)
вдруг бы тоже сомнения породил xD

@vitaxa vitaxa merged commit 8f4822e into epic/db_schema_optimization Oct 19, 2022
@vitaxa vitaxa deleted the add-exrate-listener branch October 19, 2022 07:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants