Skip to content
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

[Ep-248] Page Viewed (search) #1396

Merged
merged 17 commits into from
Mar 23, 2021
Merged

[Ep-248] Page Viewed (search) #1396

merged 17 commits into from
Mar 23, 2021

Conversation

tobitech
Copy link
Contributor

📲 What

Replace Search Page Viewed with a new event. Modify its tracking methods and unit tests.

🤔 Why

Convert Data Lake event to Segment

# Conflicts:
#	Library/Tracking/KSRAnalytics.swift
#	Library/Tracking/KSRAnalyticsTests.swift
* Write some tests to tests first visit to the page and subsequent visit after a search has been performed
* Fix broken tests after removing old data lake event
@codecov
Copy link

codecov bot commented Mar 15, 2021

Codecov Report

Merging #1396 (5405693) into master (3993afa) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1396      +/-   ##
==========================================
+ Coverage   86.07%   86.08%   +0.01%     
==========================================
  Files        1104     1104              
  Lines       97608    97707      +99     
==========================================
+ Hits        84013    84112      +99     
  Misses      13595    13595              
Impacted Files Coverage Δ
Library/Paginate.swift 100.00% <100.00%> (ø)
Library/PaginateTests.swift 100.00% <100.00%> (ø)
Library/Tracking/KSRAnalytics.swift 84.35% <100.00%> (+0.11%) ⬆️
Library/Tracking/KSRAnalyticsTests.swift 100.00% <100.00%> (ø)
Library/ViewModels/ActivitiesViewModel.swift 98.30% <100.00%> (ø)
.../ViewModels/BackerDashboardProjectsViewModel.swift 92.23% <100.00%> (ø)
Library/ViewModels/CommentsViewModel.swift 100.00% <100.00%> (ø)
Library/ViewModels/DiscoveryPageViewModel.swift 96.80% <100.00%> (ø)
Library/ViewModels/FindFriendsViewModel.swift 96.84% <100.00%> (ø)
Library/ViewModels/MessageThreadsViewModel.swift 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3993afa...5405693. Read the comment docs.

Library/Tracking/KSRAnalytics.swift Outdated Show resolved Hide resolved
Library/Tracking/KSRAnalyticsTests.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
Library/Tracking/KSRAnalytics.swift Outdated Show resolved Hide resolved
Library/Tracking/KSRAnalytics.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModelTests.swift Outdated Show resolved Hide resolved
@tobitech tobitech requested a review from singhhari March 17, 2021 19:03
Library/Tracking/KSRAnalyticsTests.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/SearchViewModel.swift Outdated Show resolved Hide resolved
@tobitech tobitech requested a review from singhhari March 19, 2021 16:01
@tobitech tobitech requested a review from singhhari March 22, 2021 21:41
@@ -43,6 +43,7 @@ public func paginate<Cursor, Value: Equatable, Envelope, ErrorEnvelope, RequestP
skipRepeats: Bool = true,
valuesFromEnvelope: @escaping ((Envelope) -> [Value]),
cursorFromEnvelope: @escaping ((Envelope) -> Cursor),
statsFromEnvelope: ((Envelope) -> Int)? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Document the parameter above this

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be marked @escaping like the rest of the parameters, given it's value relies on the network request?

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 learnt that optional closures are already escaping, the compiler shows a warning when an optional closure is marked with @escaping. More info here

@@ -11,12 +11,13 @@ final class PaginateTests: TestCase {
let requestFromCursor: (Int) -> SignalProducer<[Int], Never> = { c in .init(value: c <= 2 ? [c] : []) }
let valuesFromEnvelope: ([Int]) -> [Int] = id
let cursorFromEnvelope: ([Int]) -> Int = { ($0.last ?? 0) + 1 }
let statsFromEnvelope: ([Int]) -> Int = { _ in return 10 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you returning 10? This should probably be $0.count?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

10 is an arbitrary number I chose. Returning $0.count would return the count of results for a page during pagination, but stats is supposed to be the same regardless of the requested page.


let searchResults = Signal.merge(
stats,
viewWillAppearNotAnimated.mapConst(0).take(first: 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a brief inline comment here explaining why this needed to be done

}

func testSearchPageViewed_ReturningAfterSearching() {
let searchProjects = (1...10).map { idx in .template |> Project.lens.id .~ idx }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can delete this line and on the next line do let searchResponse = DisoveryEnvelope.template without the rest of the line and the test will have the same desired effect.

* Modify SearchViewModel test to use DiscoveryEnvelope template
# Conflicts:
#	Library/Tracking/KSRAnalyticsTests.swift
@tobitech tobitech requested a review from singhhari March 23, 2021 11:39
Copy link
Contributor

@singhhari singhhari left a comment

Choose a reason for hiding this comment

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

lgtm

@tobitech tobitech merged commit 7ba8209 into master Mar 23, 2021
@tobitech tobitech deleted the EP-248-page-viewed-search branch March 23, 2021 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants