-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat(api): add emergency contacts database functions #1081
base: master
Are you sure you want to change the base?
Conversation
datatypes.go
Outdated
@@ -222,6 +222,33 @@ func (contact *ContactData) ToTemplateContact() *templating.Contact { | |||
} | |||
} | |||
|
|||
// EmergencyContactType are Moira's special internal types of problems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
есть предложение, прекратить это дело плодить, завести папку
обозвать дататайп (выберете лучшее название)
в этом пр все, что касается эмергенси контанкта унести туда
отдельно раздербанить этот жирный файл на кучу файлов в папке
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лайк
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется, имеет смысл вынести это в отдельный PR, так как если я делаю папку datatypes
и добавлю туда файлы datatypes.go
и emergency_contacts.go
, то ломается полпроекта, тк все зависит от datatypes.go
, а если добавить в папку только emergency_contacts.go
, то разъедется логика, в разных местах будет папка и файл, что странно
} | ||
|
||
// EmergencyContacts converts redis DB reply to moira.EmergencyContact object. | ||
func EmergencyContact(rep *redis.StringCmd) (moira.EmergencyContact, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
где-то потерян глагол
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужна как публичная?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
где-то потерян глагол
Какой?
нужна как публичная?
Да
} | ||
|
||
// EmergencyContacts converts redis DB reply to moira.EmergencyContact objects array. | ||
func EmergencyContacts(rep []*redis.StringCmd) ([]*moira.EmergencyContact, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут тоже потерян глагол
нужна как публичная?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут тоже потерян глагол
Какой?
нужна как публичная?
Да
// EmergencyContactType are Moira's special internal types of problems. | ||
type EmergencyContactType string | ||
|
||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем пользователю так размазывать?
ему норм ответ - работает ли мойра или нет и все
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давайте не будем вводить кучу статусов
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и не вижу про эти статусы в ДД, откуда они взялись? :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, в диздоке мы сошлись на том, что типов проблем может быть много, на текущий момент их 5: не работает база, нет метрик, не работает чекер, не работает локальный чекер, не работает нотифаер. Пользователь будет видеть только разрешенный для выбора тип проблем (например, только отключение нотифаера, как оно будет называться в UI другой вопрос). Админы могут выбрать любой тип проблем. Это будет в другом PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я не вижу этого текста в ДД, ткнешь меня в ММ этим? :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Немного поменял нейминг и убрал все типы кроме отключения нотифаера
contact, err := reply.Contact(result) | ||
if err != nil { | ||
return contact, err | ||
return contact, fmt.Errorf("failed to reply contact '%s': %w", id, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Апочему эта штука называется reply
? Точно надо в такой форме в сообщении об ошибке писать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reply
название уже старое, это пакет который трансформирует результаты запросов в БД к структурам в Мойре, как лучше поменять тогда текст?
} | ||
|
||
emergencyContact, getEmergencyContactErr := connector.GetEmergencyContact(contactID) | ||
if getEmergencyContactErr != nil && !errors.Is(getEmergencyContactErr, database.ErrNil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если есть эмёрдженси контакт -- мы удаляем и его? Может логика должна быть наоборот, как с подписками и контактами: сначала удалите все зависимости, а потом только удаляйте контакты
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вопрос обсуждаемый и зависит от того, как это будет выглядеть в UI, если это будет галка внутри UI заполнения контакта, то логично было бы не просить пользователя отжимать галку, а просто удалять и то, и то. А если в UI будет отдельное окошко для этих контактов, то вариант с тем, чтобы пользователь сначала убирал эти контакты, а затем удалял основной имеет смысл быть. Но, честно, с учетом того, что связь 1-1, то удалять для меня выглядит более логичным вариантом
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вынесу в общее обсуждение
database/redis/emergency_contact.go
Outdated
pipe := c.TxPipeline() | ||
for _, emergencyContact := range emergencyContacts { | ||
if err := saveEmergencyContactPipe(ctx, pipe, emergencyContact); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А тут не хотим кастомное сообщение об ошибке, раз везде добавляем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Или это типа наша же функция, а не на границе с либой, так что не будем лишнюю переобёртку делать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил кастомное сообщение
database/redis/emergency_contact.go
Outdated
return nil | ||
} | ||
|
||
func saveEmergencyContactPipe(ctx context.Context, pipe redis.Pipeliner, emergencyContact moira.EmergencyContact) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По названию супер не понятно, что происходит создание пайпа, а не действие сохранение. С removeEmergencyContactPipe
то же самое
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может сделать что-то типа "addSaveEmergencyContactToPipe"...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поменял
Add emergency contacts database functions
Added database functions for emergency contacts - these are the contacts to which notifications will go to users in case of emergency types of problems in Moira