-
Notifications
You must be signed in to change notification settings - Fork 3
[TSD-40] Send the message in to all requesters with no log in the ticket #17
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
Conversation
eb91bf9 to
dcb7526
Compare
|
Currently, I don't have a template response for "No log files". Asking carl to provide them! |
ksaric
left a comment
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.
Generally very good, nice tests, a couple of minor changes and I'm not sure if we should run this before fixing that processTicket returns a single ZendeskResponse, otherwise we might send a couple of responses back to the user which will confuse him.
src/Lib.hs
Outdated
|
|
||
| processTicket :: TicketId -> App [ZendeskResponse] | ||
| processTicket ticketId = do | ||
| processTicket tid = do |
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.
tid = tId
src/Lib.hs
Outdated
| isAttachmentZip attachment = "application/zip" == aContentType attachment | ||
|
|
||
| -- | Get zendesk responses | ||
| getZendeskResponses :: [Comment] -> [Attachment] -> TicketInfo -> App [ZendeskResponse] |
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.
Isn't the mapping one TicketInfo - one ZendeskResponse? We should fix this, as noted above.
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.
My first impression is that fixing this could be a little tricky. I'll try to fix it today and if I couldn't get it done by today, then I'll have to ask for your help
src/Lib.hs
Outdated
| isTicketBlacklisted :: TicketInfo -> Bool | ||
| isTicketBlacklisted TicketInfo{..} = ticketId `notElem` [9377,10815] | ||
|
|
||
| isGoguenTestnetTicket :: TicketInfo -> Bool |
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.
isTicketInGoguenTestnet
src/Lib.hs
Outdated
| ticketsFilter ticketInfo = | ||
| isTicketAnalyzed ticketInfo && isTicketOpen ticketInfo && isTicketBlacklisted ticketInfo | ||
| ticketsFilter ticketInfo = | ||
| all (\predicate -> predicate ticketInfo) [ isTicketAnalyzed |
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.
A complicated way to say a simple thing. Remember that you will have to maintain this code and that doing something smart may not be the best things to do - do something simple instead.
I know it seems kind of harsh to say that, but it's important that you understand how little changes like these make the code more complex. I actually have to think about this, which is something I like to avoid as much as possible.
And if this builds, isn't all ticketInfo [ ... ] an option?
test/Spec.hs
Outdated
| zendeskResponses <- run appExecution | ||
| assert $ not (null zendeskResponses) && not (isTaggedWithNoLogs zendeskResponses) | ||
|
|
||
| isTaggedWithNoLogs :: [ZendeskResponse] -> Bool |
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.
Can you insert the param name? I know this is also a convention, but I have to look at the type to know what this is doing, which is not helping readability.
Try to be as explicit as possible, it helps readability and maintainability.
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.
Sorry, I'm not sure what this means. Do you want me to fix the name of the function?
src/Lib.hs
Outdated
| getZendeskResponses :: [Comment] -> [Attachment] -> TicketInfo -> App [ZendeskResponse] | ||
| getZendeskResponses comments attachments ticketInfo | ||
| | not (null attachments) = mapM (inspectAttachment ticketInfo) attachments | ||
| | not (null comments) = pure <$> responseNoLogs ticketInfo |
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.
pure <$> responseNoLogs ticketInfo == responseNoLogs ticketInfo
src/Lib.hs
Outdated
| mapM_ extractEmailAddress ticketIds | ||
|
|
||
|
|
||
| processTicket :: TicketId -> App [ZendeskResponse] |
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.
We need to fix this. We should take the last comment attachments and process the last attachment.
test/Spec.hs
Outdated
|
|
||
| zendeskResponses <- run appExecution | ||
|
|
||
| assert $ not (null zendeskResponses) && isTaggedWithNoLogs zendeskResponses |
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.
Very nice 👍
| forAll arbitrary $ \ticketInfo -> | ||
| monadicIO $ do | ||
|
|
||
| pre $ any (not . null . cAttachments) comments |
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.
all (not . null . cAttachments) comments - we require that all the comments have attachments, right?
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.
Well, I thought the intended behavior was that if user had submitted multiple comments and at least one of them has log file attached(so not all comments needs log file), then processTicket should return ZendeskResponses
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.
Yes, good thinking but I didn't even notice we were returning multiple ZendeskResponse, my bad.
HirotoShioi
left a comment
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.
Fixed most of the things, I'll try to apply the fix but it might be little tricky.
| forAll arbitrary $ \ticketInfo -> | ||
| monadicIO $ do | ||
|
|
||
| pre $ any (not . null . cAttachments) comments |
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.
Well, I thought the intended behavior was that if user had submitted multiple comments and at least one of them has log file attached(so not all comments needs log file), then processTicket should return ZendeskResponses
test/Spec.hs
Outdated
| zendeskResponses <- run appExecution | ||
| assert $ not (null zendeskResponses) && not (isTaggedWithNoLogs zendeskResponses) | ||
|
|
||
| isTaggedWithNoLogs :: [ZendeskResponse] -> Bool |
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.
Sorry, I'm not sure what this means. Do you want me to fix the name of the function?
src/Lib.hs
Outdated
| isAttachmentZip attachment = "application/zip" == aContentType attachment | ||
|
|
||
| -- | Get zendesk responses | ||
| getZendeskResponses :: [Comment] -> [Attachment] -> TicketInfo -> App [ZendeskResponse] |
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.
My first impression is that fixing this could be a little tricky. I'll try to fix it today and if I couldn't get it done by today, then I'll have to ask for your help
ksaric
left a comment
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.
Great work, just a few more little details.
src/Lib.hs
Outdated
| inspectAttachments :: TicketInfo -> [Attachment] -> App (Maybe ZendeskResponse) | ||
| inspectAttachments ticketInfo attachments = do | ||
| -- Inspecting the last element since it'll be the latest attachment | ||
| let latestAttachment = last <$> nonEmpty attachments |
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.
How about inspectAttachment ticketInfo =<< safeHead . sort $ attachments where the Ord instance should be AttachmentId? Or the expanded form of the same which is even better.
src/Lib.hs
Outdated
| inspectAttachments ticketInfo attachments = do | ||
| -- Inspecting the last element since it'll be the latest attachment | ||
| let latestAttachment = last <$> nonEmpty attachments | ||
| case latestAttachment of |
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.
This should be a bind - latestAttachment >>= \att -> inspectAttachment ticketInfo att or similar.
See how they align? Nothing goes to Nothing while Just goes to Just.
You do work when it's Just otherwise return nothing.
| forAll arbitrary $ \ticketInfo -> | ||
| monadicIO $ do | ||
|
|
||
| pre $ any (not . null . cAttachments) comments |
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.
Yes, good thinking but I didn't even notice we were returning multiple ZendeskResponse, my bad.
- Unwrap newtype so the request api will be valid - Make assignee_id field to be maybe since ticket could be unassigned in that case classifier will not be able to parse the json
Description
This PR will introduce responses to tickets with no logs attached.
Related issue
https://iohk.myjetbrains.com/youtrack/issue/TSD-40