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

Subscribers line chart #20706

Merged
merged 26 commits into from
Apr 26, 2024
Merged

Subscribers line chart #20706

merged 26 commits into from
Apr 26, 2024

Conversation

irfano
Copy link
Member

@irfano irfano commented Apr 23, 2024

Fixes #20687

This adds a line graph card to the Subscribers tab of Stats.
It displays a graph of the total subscriber count for the last 30 days. If you tap on line, you'll see the data for that specific point. The marker view is the same as the marker on the "Views & Visitors" card. Most of the design details were taken from the "Views & Visitors" card.

Tip

Review tip

Some classes are copied from existing classes, but they also include some modifications. I copied some same functions intentionally, since it will be easier to remove old classes when we remove stats_traffic_subscribers_tab flag.

  • LineChartMarkerViewSubscribersMarkerView
  • LineChartViewHolderSubscribersChartViewHolder
  • LineChartLabelFormatterSubscribersChartLabelFormatter
  • ViewsAndVisitorsUseCaseTestSubscribersChartUseCaseTest

To Test:

  1. Enabled stats_traffic_subscribers_tab from My site → Debug settings.
  2. Navigate back and open My Site → Stats.
  3. Open SUBSCRIBERS tab.
  4. Tap on the line to see marker view.

Regression Notes

  1. Potential unintended areas of impact

    • None
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • N/A
  3. What automated tests I added (or what prevented me from doing so)

    • Added SubscribersChartUseCaseTest

PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones):

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@irfano irfano added this to the 24.8 milestone Apr 23, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Apr 23, 2024

4 Warnings
⚠️ strings.xml files should only be updated on release branches, when the translations are downloaded by our automation.
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class SubscribersUseCaseFactory is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class SubscribersChartLabelFormatter is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 23, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20706-f0ddce1
Commitf0ddce1
Direct Downloadjetpack-prototype-build-pr20706-f0ddce1.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 23, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20706-f0ddce1
Commitf0ddce1
Direct Downloadwordpress-prototype-build-pr20706-f0ddce1.apk
Note: Google Login is not supported on these builds.

@irfano irfano force-pushed the issue/20687-subscribers-line-chart branch from 55ca517 to 39d117c Compare April 24, 2024 13:58
@irfano irfano marked this pull request as ready for review April 24, 2024 15:29
Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 21.27660% with 111 lines in your changes are missing coverage. Please review.

Project coverage is 40.60%. Comparing base (5efa916) to head (f0ddce1).
Report is 6 commits behind head on trunk.

Files Patch % Lines
...ss/android/ui/stats/refresh/lists/UiModelMapper.kt 7.14% 50 Missing and 2 partials ⚠️
...ections/subscribers/usecases/SubscribersUseCase.kt 53.33% 17 Missing and 4 partials ⚠️
...sections/subscribers/usecases/SubscribersMapper.kt 0.00% 12 Missing ⚠️
...press/android/ui/stats/refresh/utils/StatsUtils.kt 0.00% 10 Missing ⚠️
...d/ui/stats/refresh/lists/sections/BlockListItem.kt 12.50% 7 Missing ⚠️
...ts/refresh/utils/SubscribersChartLabelFormatter.kt 0.00% 6 Missing ⚠️
...droid/ui/stats/refresh/utils/StatsDateFormatter.kt 33.33% 2 Missing ⚠️
.../wordpress/android/ui/stats/refresh/StatsModule.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #20706      +/-   ##
==========================================
- Coverage   40.62%   40.60%   -0.03%     
==========================================
  Files        1485     1488       +3     
  Lines       68330    68436     +106     
  Branches    11302    11315      +13     
==========================================
+ Hits        27760    27787      +27     
- Misses      38054    38129      +75     
- Partials     2516     2520       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@irfano irfano requested a review from aditi-bhatia April 24, 2024 17:17
Copy link
Contributor

@aditi-bhatia aditi-bhatia left a comment

Choose a reason for hiding this comment

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

I'm seeing this chart on the mobile.blog site as well as a few others I tested with, which looks incorrect 🤔 I tested using a local build as well as the apk downloaded from this PR. I haven't spent too much time debugging this yet, but the y-axis is missing and tapping on the line isn't scrollable + only shows the value for Apr 25:

Screenshot 2024-04-24 at 5 17 19 PM

@@ -76,6 +78,48 @@ class UiModelMapper
return mapStatsWithOverview(TimeStatsType.OVERVIEW, useCaseModels, showError)
}

@Suppress("CyclomaticComplexMethod")
fun mapSubscribers(useCaseModels: List<UseCaseModel>, showError: (Int) -> Unit): UiModel {
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed a lot of this function's contents are similar to mapInsights() and mapStats(). Do you think we could consolidate some of the repetition into helper functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I consolidated (fd93f16) some parts of it, there are slight differences in other parts regarding handling nullability. I don't want to make further changes to avoid affecting the production.

}
val allFailingWithoutData = useCaseModels.fold(true) { acc, useCaseModel ->
acc && useCaseModel.state == ERROR && useCaseModel.data == null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is being used in both mapInsights() and in mapSubscribers() for example, and could probably be brought out into their own short functions. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done: fd93f16

@irfano
Copy link
Member Author

irfano commented Apr 25, 2024

I'm seeing this chart on the mobile.blog site as well as a few others I tested with, which looks incorrect

Good catch! I addressed it (60b9408) by matching the behavior with the web. I set the min value to 0 and the max value to twice of subscribers count if there is no change on the line.

@irfano irfano requested a review from aditi-bhatia April 25, 2024 14:02
Copy link

sonarcloud bot commented Apr 25, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
14.2% Duplication on New Code (required ≤ 10%)

See analysis details on SonarCloud

@wpmobilebot
Copy link
Contributor

Found 1 violations:

The PR caused some dependency changes (expand to see details)

-+--- org.wordpress:fluxc:{strictly trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e} -> trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e
-|    +--- org.wordpress:wellsql:2.0.0
-|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
-|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
-|    +--- org.wordpress.fluxc:fluxc-annotations:trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e
-|    +--- org.greenrobot:eventbus:3.3.1
-|    |    \--- org.greenrobot:eventbus-java:3.3.1
-|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
-|    +--- com.android.volley:volley:1.1.1 -> 1.2.1
-|    +--- androidx.paging:paging-runtime:2.1.2
-|    |    +--- androidx.paging:paging-common:2.1.2
-|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
-|    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.2.0 (*)
-|    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.2.0 (*)
-|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.6.2 (*)
-|    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2 (*)
-|    |    \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
-|    +--- com.goterl:lazysodium-android:5.0.2
-|    +--- net.java.dev.jna:jna:5.5.0
-|    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.9.10 (*)
-|    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.20 -> 1.9.22 (*)
-|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
-|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
-|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6 (*)
-|    +--- androidx.security:security-crypto:1.0.0
-|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
-|    |    \--- com.google.crypto.tink:tink-android:1.5.0
-|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0 -> 4.9.2 (*)
-|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-|    +--- org.apache.commons:commons-text:1.10.0
-|    |    \--- org.apache.commons:commons-lang3:3.12.0
-|    +--- androidx.room:room-runtime:2.4.2 -> 2.5.0
-|    |    +--- androidx.annotation:annotation-experimental:1.1.0 -> 1.3.1 (*)
-|    |    +--- androidx.arch.core:core-runtime:2.0.1 -> 2.2.0 (*)
-|    |    +--- androidx.room:room-common:2.5.0
-|    |    |    +--- androidx.annotation:annotation:1.3.0 -> 1.6.0 (*)
-|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> 1.9.10 (*)
-|    |    +--- androidx.sqlite:sqlite:2.3.0
-|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
-|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
-|    |    \--- androidx.sqlite:sqlite-framework:2.3.0
-|    |         +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
-|    |         +--- androidx.sqlite:sqlite:2.3.0 (*)
-|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
-|    +--- androidx.room:room-ktx:2.4.2 -> 2.5.0
-|    |    +--- androidx.room:room-common:2.5.0 (*)
-|    |    +--- androidx.room:room-runtime:2.5.0 (*)
-|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
-|    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.3 (*)
-|    +--- com.google.dagger:dagger:2.42 -> 2.50
-|    |    \--- javax.inject:javax.inject:1
-|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.7.3 (*)
-|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.7.3 (*)
++--- org.wordpress:fluxc:{strictly 2993-d6cb0eded15c3dbbb924172ab3d1c5d8431f1be3} -> 2993-d6cb0eded15c3dbbb924172ab3d1c5d8431f1be3
+|    +--- org.wordpress:wellsql:2.0.0
+|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
+|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
+|    +--- org.wordpress.fluxc:fluxc-annotations:2993-d6cb0eded15c3dbbb924172ab3d1c5d8431f1be3
+|    +--- org.greenrobot:eventbus:3.3.1
+|    |    \--- org.greenrobot:eventbus-java:3.3.1
+|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
+|    +--- com.android.volley:volley:1.1.1 -> 1.2.1
+|    +--- androidx.paging:paging-runtime:2.1.2
+|    |    +--- androidx.paging:paging-common:2.1.2
+|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
+|    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.2.0 (*)
+|    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.2.0 (*)
+|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.6.2 (*)
+|    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2 (*)
+|    |    \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
+|    +--- com.goterl:lazysodium-android:5.0.2
+|    +--- net.java.dev.jna:jna:5.5.0
+|    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.9.10 (*)
+|    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.20 -> 1.9.22 (*)
+|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
+|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
+|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6 (*)
+|    +--- androidx.security:security-crypto:1.0.0
+|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
+|    |    \--- com.google.crypto.tink:tink-android:1.5.0
+|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0 -> 4.9.2 (*)
+|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
+|    +--- org.apache.commons:commons-text:1.10.0
+|    |    \--- org.apache.commons:commons-lang3:3.12.0
+|    +--- androidx.room:room-runtime:2.4.2 -> 2.5.0
+|    |    +--- androidx.annotation:annotation-experimental:1.1.0 -> 1.3.1 (*)
+|    |    +--- androidx.arch.core:core-runtime:2.0.1 -> 2.2.0 (*)
+|    |    +--- androidx.room:room-common:2.5.0
+|    |    |    +--- androidx.annotation:annotation:1.3.0 -> 1.6.0 (*)
+|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> 1.9.10 (*)
+|    |    +--- androidx.sqlite:sqlite:2.3.0
+|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
+|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+|    |    \--- androidx.sqlite:sqlite-framework:2.3.0
+|    |         +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
+|    |         +--- androidx.sqlite:sqlite:2.3.0 (*)
+|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+|    +--- androidx.room:room-ktx:2.4.2 -> 2.5.0
+|    |    +--- androidx.room:room-common:2.5.0 (*)
+|    |    +--- androidx.room:room-runtime:2.5.0 (*)
+|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+|    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.3 (*)
+|    +--- com.google.dagger:dagger:2.42 -> 2.50
+|    |    \--- javax.inject:javax.inject:1
+|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.7.3 (*)
+|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.7.3 (*)
 \--- org.wordpress:login:1.15.0
-     \--- org.wordpress:fluxc:trunk-ed60798b4d96ec19863c74b0f525e2e20f4525db -> trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e (*)
+     \--- org.wordpress:fluxc:trunk-ed60798b4d96ec19863c74b0f525e2e20f4525db -> 2993-d6cb0eded15c3dbbb924172ab3d1c5d8431f1be3 (*)

Please review and act accordingly

Copy link
Contributor

@aditi-bhatia aditi-bhatia 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 to me 👍

@irfano irfano merged commit 61b6dd0 into trunk Apr 26, 2024
19 of 20 checks passed
@irfano irfano deleted the issue/20687-subscribers-line-chart branch April 26, 2024 11:45
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.

Subscribers Line Chart Card
4 participants