Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Fix for "Mentioned issues are not sorted by date" #2663

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akarataev
Copy link
Contributor

Issue mentioned in #2649
I've implement sorting Array<InboxDashboardModel> by date for mentioned filter type.

@Huddie Huddie added the 💤 awaiting review Pull Request is awaiting code reviews label Mar 5, 2019
@@ -24,6 +24,14 @@ extension NotificationViewModel {
}
}

// sorting Array<InboxDashboardModel> by date for mentioned filter type
extension Array where Element == InboxDashboardModel {
func sortedMentionedByDate(_ predicate: Bool = true, filter: V3IssuesRequest.FilterType) -> [Element] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, what's the reason for the predicate? When would you want to call this with false? That would just no-op, if I understand this correctly 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was a good place for feature toggle. I removed this argument.

@@ -24,6 +24,14 @@ extension NotificationViewModel {
}
}

// sorting Array<InboxDashboardModel> by date for mentioned filter type
extension Array where Element == InboxDashboardModel {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would also be 💯 if we can add a test for this one!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added tests for this functionality.

@BasThomas
Copy link
Collaborator

Thanks for picking this up @akarataev!

@BasThomas BasThomas added 😴 awaiting changes Changes requested, waiting on author to update and removed 💤 awaiting review Pull Request is awaiting code reviews labels Mar 9, 2019
@akarataev akarataev force-pushed the 2649-mentioned-sorted-by-date branch from 2a46011 to c416fa7 Compare March 9, 2019 15:10
@akarataev
Copy link
Contributor Author

Hello @BasThomas,

I made a changes, please see it.

@BasThomas BasThomas added 💤 awaiting review Pull Request is awaiting code reviews and removed 😴 awaiting changes Changes requested, waiting on author to update labels Mar 9, 2019
Copy link
Collaborator

@BasThomas BasThomas left a comment

Choose a reason for hiding this comment

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

Looks good. I just remembered that we'd probably want to give this as an option though, instead of, like Ryan said, doing manipulation on the client. What do you think? @akarataev?

XCTAssert(zip(mentionedSorted,
mentionedSorted.sorted(by: {$0.date > $1.date}))
.map { $0.date == $1.date }
.reduce(true) { $0 && $1 }, "Mentioned is not sorted by day")
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use SE-0207's allSatisfy here ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow 😲
I did not know about it. Fixed it.

isPullRequest: false, state: .open
)
}
static func provide(number: Int, with interval: TimeInterval = TimeInterval(86400)) -> [InboxDashboardModel] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Neat :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm.. I thought it was a linter configuration.

Снимок экрана 2019-03-10 в 19 49 38

@BasThomas BasThomas added 😴 awaiting changes Changes requested, waiting on author to update and removed 💤 awaiting review Pull Request is awaiting code reviews labels Mar 10, 2019
@akarataev akarataev force-pushed the 2649-mentioned-sorted-by-date branch from c416fa7 to 75003f3 Compare March 10, 2019 12:54
@akarataev
Copy link
Contributor Author

@BasThomas

I can help design UI for this option. Do you have any suggestions?

@BasThomas
Copy link
Collaborator

BasThomas commented Mar 10, 2019

What do you think about a filter (a là Mail.app on iOS) in the top right? Would only be there for mentioned then. Don't think we should show it but leave it disabled in other views.

Take that advice/opinion with a (big) grain of salt though; I'm definitely not a designer 😄

@akarataev
Copy link
Contributor Author

@BasThomas

I can prepare several design options. How do you look at closing this PR under feature flag? And the development of the interface to make a separate task.

@BasThomas
Copy link
Collaborator

Hm, I don't think we've used feature flags for that before. Not opposed to it if we keep it documented in a document as well.

@Huddie
Copy link
Collaborator

Huddie commented Mar 13, 2019

I don’t think giving sorted/unsorted options removes the issue Ryan was worried about since if a user selected the Sorted option we would be sorting on the client and possibly causing some out of sync issue with GitHub. Not sure why sorting would cause an issue but Ryan thought it might. Maybe wait for Ryan before we officially merge ?

Sent with GitHawk

@akarataev
Copy link
Contributor Author

@Huddie,
Ryan said what exactly should be out of sync?

@ijm8710
Copy link

ijm8710 commented Mar 13, 2019

I agree with @Huddie, the last comment here was Ryan’s comment on it. I believe i was first to bring this all up, so trust me I’m all in favor of the sort in itself but sounds like Ryan wanted to keep things as dumbed down as possible so hopefully we can touch base with him on this before merging when he returns.

@BasThomas
Copy link
Collaborator

OK, let's leave this one open for now then 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
😴 awaiting changes Changes requested, waiting on author to update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants