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
refactor(condo): DOMA-6931 refactored news sending #4501
refactor(condo): DOMA-6931 refactored news sending #4501
Conversation
09239d2
to
92ebb7f
Compare
apps/condo/domains/news/gql.js
Outdated
@@ -12,7 +12,7 @@ const { ADDRESS_META_SUBFIELDS_TABLE_LIST } = require('@condo/domains/property/s | |||
|
|||
const COMMON_FIELDS = 'id dv sender { dv fingerprint } v deletedAt newId createdBy { id name } updatedBy { id name } createdAt updatedAt' | |||
|
|||
const NEWS_ITEM_FIELDS = `{ organization { id } number title body type validBefore sendAt sentAt isPublished publishedAt ${COMMON_FIELDS} compactScopes { count firstOnes { id unitType unitName property { address addressMeta { ${ADDRESS_META_SUBFIELDS_TABLE_LIST} } } } } }` | |||
const NEWS_ITEM_FIELDS = `{ organization { id } number title body type validBefore sendAt deliverAt sentAt isPublished publishedAt ${COMMON_FIELDS} compactScopes { count firstOnes { id unitType unitName property { address addressMeta { ${ADDRESS_META_SUBFIELDS_TABLE_LIST} } } } } }` |
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.
Its better to call it deliveredAt, since delivered is in past tense
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.
No, it's future tense, not past tense.
This is equivalent to:
sendAt
- for news to be sent in the futurepublishedAt
+ time to cancel sending 15 seconds - for news to be sent now
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.
I will add a description to this pr to make it clearer what is changing
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.
Alright, got you
But this seems really counter intuitive.. Need docs or better naming
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.
Unfortunately, the name sendTo
is already taken :(
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.
or better naming
Ok, I'll think about it
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.
Just to be clear:
Why couldnt we set sendAt to publishedAt + time to cancel sending 15 seconds - for news to be sent now
?
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.
Yeah, I wanted to do that, but...
Now the sendAt
field is an indicator that the news was sent with a planned sending date in the future.
If it is full, then the news is planned; if it is empty, then the news is being sent right now.
I can’t yet say for sure whether we need this information now or whether this information may be useful in the future, but if we start always filling out the sendAt
field, we will lose it.
However, we can add a separate flag for this. (If needed)
I think it's worth discussing this point. if it doesn't affect anything, then why not
type: 'DateTimeUtc', | ||
}, | ||
|
||
deliverAt: { | ||
// todo(DOMA-6931): update schemaDoc |
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.
6931 is solved by this PR, is it not? I think we should remove this PR
@@ -828,7 +828,8 @@ describe('NewsItems', () => { | |||
) | |||
}) | |||
|
|||
test('must throw an error on trying to edit the news item which already been sent', async () => { | |||
// todo(doma-6931): rewrite test |
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.
^^
}) | ||
}) | ||
|
||
describe('should be auto-calculate', () => { |
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.
describe('should be auto-calculate', () => { | |
describe('should be auto-calculated', () => { |
@@ -136,10 +136,40 @@ const NewsItem = new GQLListSchema('NewsItem', { | |||
}, | |||
|
|||
sendAt: { |
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.
what will happen with this value if user decides to click "No I do not want to send this newsItem"
Also, I think we should reuse 15 seconds from frontned part of our app. Otherwise we will change 15 to 30 in one place. and forget to change in other place
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.
if user decides to click "No I do not want to send this newsItem"
This news item will be deleted (using deletedAt
)
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.
Also, I think we should reuse 15 seconds from frontned part of our app. Otherwise we will change 15 to 30 in one place. and forget to change in other place
Fixed
type: defineMessageType(newsItem), | ||
meta: { | ||
dv: 1, | ||
title: truncate(newsItem.title, { length: TITLE_MAX_LEN, separator: ' ', omission: '...' }), |
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.
It might be better to use deidcated …
char here, since it might
(im not sure) take less space in the resulting message
Need to check whether the target system support the encodings though
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.
I think there is no need to change something that already works well :)
92ebb7f
to
871fcd0
Compare
9d87ebf
to
536deef
Compare
536deef
to
7e2f166
Compare
apps/condo/pages/news/[id]/index.tsx
Outdated
@@ -83,6 +85,8 @@ const NewsItemCard: React.FC = () => { | |||
const ConfirmDeleteMessage = intl.formatMessage({ id: 'news.ConfirmDeleteMessage' }) | |||
const CancelMessage = intl.formatMessage({ id: 'news.CancelMessage' }) | |||
|
|||
const { publicRuntimeConfig: { newsItemsSendingDelay } } = getConfig() |
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.
move this outside of component
5b62394
to
4604ee4
Compare
4604ee4
to
a80e3ef
Compare
Quality Gate passedIssues Measures |
what's going on here?
changes in the
NewsItem
schema:Before:
sendAt
is set in when the news should be postponedAfter:
sendAt
field is now always set in (сan benull
if not ready to send yet whenisPublished = false
), and indicates the date when the news sending should beginchanges in tasks
Before:
notifyResidentsAboutNewsItem
task usedsetTimeout
and because of this we could not track the sending process, since the worker completed the task before the news sending process was completedAfter:
notifyResidentsAboutNewsItem
task has been refactored and now does not usesetTimeout
changes in accesses
Before:
After:
Other