wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.92k stars 1.3k forks source link

Subscribers line chart #20706

Closed irfano closed 2 weeks ago

irfano commented 3 weeks ago

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:


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

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

Generated by :no_entry_sign: Danger

wpmobilebot commented 3 weeks ago
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
Commitf0ddce1dec0bf543ef818723e85a5cfc52f36c5f
Direct Downloadjetpack-prototype-build-pr20706-f0ddce1.apk
Note: Google Login is not supported on these builds.
wpmobilebot commented 3 weeks ago
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
Commitf0ddce1dec0bf543ef818723e85a5cfc52f36c5f
Direct Downloadwordpress-prototype-build-pr20706-f0ddce1.apk
Note: Google Login is not supported on these builds.
codecov[bot] commented 2 weeks ago

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 :warning:
...ections/subscribers/usecases/SubscribersUseCase.kt 53.33% 17 Missing and 4 partials :warning:
...sections/subscribers/usecases/SubscribersMapper.kt 0.00% 12 Missing :warning:
...press/android/ui/stats/refresh/utils/StatsUtils.kt 0.00% 10 Missing :warning:
...d/ui/stats/refresh/lists/sections/BlockListItem.kt 12.50% 7 Missing :warning:
...ts/refresh/utils/SubscribersChartLabelFormatter.kt 0.00% 6 Missing :warning:
...droid/ui/stats/refresh/utils/StatsDateFormatter.kt 33.33% 2 Missing :warning:
.../wordpress/android/ui/stats/refresh/StatsModule.kt 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

irfano commented 2 weeks ago

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 (60b9408e8b205e2969713c91c3eab81de27ca88c) 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.

sonarcloud[bot] commented 2 weeks ago

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarCloud

wpmobilebot commented 2 weeks ago

Found 1 violations:

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

```diff -+--- 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