Skip to content

[Dynamic Dashboard] Coupons Card, part 1 #11531

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

Merged
merged 17 commits into from
May 21, 2024
Merged

Conversation

hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented May 16, 2024

Part of: #11508

Description

This PR is part of the work to add the coupons card, it adds the following:

  1. It builds on top of Coupons/fetch reports wordpress-mobile/WordPress-FluxC-Android#3012 to add the needed logic to the repository.
  2. It adds the ViewModel for the card with all the business logic.
  3. It adds the logic of the range selection.
  4. It adds a basic UI to test the logic.
  5. Renaming and moving few classes around for a better organization.

The final UI will be added separately to keep the size of the PR manageable.

Testing instructions

  1. Prepare some test data: create some coupons, and add them to some orders (you can do it from wp-admin even for old orders).
  2. Open the app.
  3. Enable the coupons card.
  4. Confirm the coupons are loaded for the selected range.
  5. Change the range and confirm the coupons are fetched for the new one.
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@hichamboushaba hichamboushaba added type: enhancement A request for an enhancement. status: do not merge Dependent on another PR, ready for review but not ready for merge. feature: dashboard Related to home screen project labels May 16, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 16, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
FlavorJalapeno
Build TypeDebug
Commit296306d
Direct Downloadwoocommerce-prototype-build-pr11531-296306d.apk

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

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

Project coverage is 40.32%. Comparing base (2b56352) to head (d2eed91).

Current head d2eed91 differs from pull request most recent head ce4a02e

Please upload reports for the commit ce4a02e to get more accurate results.

Files Patch % Lines
.../ui/dashboard/coupons/DashboardCouponsViewModel.kt 0.00% 91 Missing ⚠️
...droid/ui/dashboard/coupons/DashboardCouponsCard.kt 0.00% 70 Missing ⚠️
...woocommerce/android/ui/coupons/CouponRepository.kt 0.00% 16 Missing ⚠️
...ui/dashboard/coupons/GetSelectedRangeForCoupons.kt 0.00% 6 Missing ⚠️
.../kotlin/com/woocommerce/android/AppPrefsWrapper.kt 0.00% 5 Missing ⚠️
...rc/main/kotlin/com/woocommerce/android/AppPrefs.kt 0.00% 4 Missing ⚠️
...ommerce/android/ui/dashboard/DashboardContainer.kt 0.00% 3 Missing ⚠️
...ce/android/ui/dashboard/data/DashboardDataStore.kt 0.00% 3 Missing ⚠️
.../dashboard/data/CouponsCustomDateRangeDataStore.kt 0.00% 2 Missing ⚠️
...e/android/ui/dashboard/stats/DashboardStatsCard.kt 0.00% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #11531      +/-   ##
============================================
- Coverage     40.44%   40.32%   -0.13%     
- Complexity     5196     5197       +1     
============================================
  Files          1083     1087       +4     
  Lines         62996    63198     +202     
  Branches       8628     8672      +44     
============================================
+ Hits          25479    25483       +4     
- Misses        35224    35421     +197     
- Partials       2293     2294       +1     

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

@hichamboushaba hichamboushaba requested a review from 0nko May 16, 2024 22:02
@hichamboushaba hichamboushaba marked this pull request as ready for review May 16, 2024 22:03
@hichamboushaba hichamboushaba force-pushed the issue/11508-coupons-card branch from b8fe836 to 18a88d8 Compare May 17, 2024 07:52
@dangermattic
Copy link
Collaborator

dangermattic commented May 17, 2024

6 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class DashboardCouponsViewModel is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class Loaded is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class DateRangeState is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class OpenDatePicker is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class GetSelectedRangeForCoupons is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@hichamboushaba hichamboushaba added this to the 18.8 milestone May 17, 2024
@hichamboushaba hichamboushaba force-pushed the issue/11508-coupons-card branch from 18a88d8 to e09b251 Compare May 17, 2024 11:55
@hichamboushaba hichamboushaba force-pushed the issue/11508-coupons-card branch from d2eed91 to 58d48aa Compare May 17, 2024 17:14
@0nko 0nko self-assigned this May 20, 2024
Copy link
Contributor

@0nko 0nko left a comment

Choose a reason for hiding this comment

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

Nice work! I've observed a couple of things while testing the PR:

  • When I first selected the custom range, the range picker was shown but after specifying a range, the menu was not updated and I couldn't select the custom range after that
Screen_recording_20240520_145056.webm
  • I don't see coupons that were applied manually to older orders (for any data range)

image

@hichamboushaba
Copy link
Member Author

Thanks @0nko for the review

When I first selected the custom range, the range picker was shown but after specifying a range, the menu was not updated and I couldn't select the custom range after that

I used the wrong function for setting the active tab (I'm not sure why I didn't notice this while testing, I'm quite sure I tested this scenario 😕), this now should be fixed.

I don't see coupons that were applied manually to older orders (for any data range)

All I can think of is that maybe the analytics weren't calculated on the backend yet when you tested (they take a short amount of time), can you please re-test it now?

Copy link
Contributor

@0nko 0nko left a comment

Choose a reason for hiding this comment

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

The custom range works as expected now. I'm not sure why, but I don't see the coupons that were applied manually 🤷. Anyway, that's not really a problem.

Nice work! 🎖️

@hichamboushaba
Copy link
Member Author

The custom range works as expected now. I'm not sure why, but I don't see the coupons that were applied manually 🤷. Anyway, that's not really a problem.

Can you see them in the Analytics section of wp-admin?

@0nko
Copy link
Contributor

0nko commented May 21, 2024

I can see it showed up now both on the web and the app 🤔, maybe I really just needed to wait..

@hichamboushaba hichamboushaba enabled auto-merge May 21, 2024 11:35
@hichamboushaba hichamboushaba removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label May 21, 2024
@wpmobilebot
Copy link
Collaborator

Found 1 violations:

The PR caused the following dependency changes:

expand

-+--- org.wordpress:fluxc:2.79.2
-|    +--- org.wordpress:wellsql:2.0.0
-|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
-|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
-|    +--- org.wordpress.fluxc:fluxc-annotations:2.79.2
-|    +--- org.greenrobot:eventbus:3.3.1 (*)
-|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
-|    +--- com.android.volley:volley:1.1.1 -> 1.2.0
-|    +--- androidx.paging:paging-runtime:2.1.2
-|    |    +--- androidx.paging:paging-common:2.1.2
-|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.7.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.2 (*)
-|    +--- 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
-|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
-|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
-|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.2 (*)
-|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6
-|    |    \--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
-|    +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
-|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.7.0 (*)
-|    |    +--- com.google.crypto.tink:tink-android:1.5.0
-|    |    \--- androidx.collection:collection:1.1.0 -> 1.4.0 (*)
-|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
-|    |    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
-|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.9.10 (*)
-|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-|    +--- org.apache.commons:commons-text:1.10.0 (*)
-|    +--- androidx.room:room-runtime:2.4.2 -> 2.5.2 (*)
-|    +--- androidx.room:room-ktx:2.4.2 -> 2.5.2
-|    |    +--- androidx.room:room-common:2.5.2 (*)
-|    |    +--- androidx.room:room-runtime:2.5.2 (*)
-|    |    +--- 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:trunk-09a0d45d25140a4b50095b1555ef6f1b0f7c510c FAILED
-+--- org.wordpress.fluxc.plugins:woocommerce:2.79.2
-|    +--- org.wordpress:wellsql:2.0.0 (*)
-|    +--- org.wordpress.fluxc:fluxc-annotations:2.79.2
-|    +--- androidx.room:room-ktx:2.4.2 -> 2.5.2 (*)
-|    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.9.10 (*)
-|    +--- org.wordpress:fluxc:2.79.2 (*)
-|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-|    +--- com.google.dagger:dagger:2.42 -> 2.50 (*)
-|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.7.3 (*)
-|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.7.3 (*)
-|    \--- androidx.room:room-runtime:2.4.2 -> 2.5.2 (*)
++--- org.wordpress.fluxc.plugins:woocommerce:trunk-09a0d45d25140a4b50095b1555ef6f1b0f7c510c FAILED
 +--- org.wordpress:login:1.15.0
 |    +--- com.github.bumptech.glide:glide:4.12.0 -> 4.16.0
-|    |    \--- androidx.exifinterface:exifinterface:1.3.6 (*)
+|    |    \--- androidx.exifinterface:exifinterface:1.3.6
+|    |         \--- androidx.annotation:annotation:1.2.0 -> 1.7.0 (*)
-|    \--- com.google.dagger:dagger:2.47 -> 2.50 (*)
+|    \--- com.google.dagger:dagger:2.47 -> 2.50
+|         \--- javax.inject:javax.inject:1
 \--- project :libs:cardreader
      +--- com.stripe:stripeterminal-localmobile:3.1.1
      |    \--- org.jetbrains.kotlin:kotlin-parcelize-runtime:1.8.22 -> 1.9.22
-     |         \--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.9.22 (*)
+     |         \--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.9.22
+     |              \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
      \--- com.stripe:stripeterminal-core:3.1.1
-          +--- androidx.security:security-crypto:1.1.0-alpha03 (*)
+          +--- androidx.security:security-crypto:1.1.0-alpha03
+          |    +--- androidx.annotation:annotation:1.1.0 -> 1.7.0 (*)
+          |    +--- com.google.crypto.tink:tink-android:1.5.0
+          |    \--- androidx.collection:collection:1.1.0 -> 1.4.0 (*)
-          \--- androidx.room:room-ktx:2.5.2 (*)
+          \--- androidx.room:room-ktx:2.5.2
+               +--- androidx.room:room-common:2.5.2 (*)
+               +--- androidx.room:room-runtime:2.5.2 (*)
+               +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+               \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.3 (*)

Please review and act accordingly

@hichamboushaba hichamboushaba merged commit dd01fde into trunk May 21, 2024
13 of 15 checks passed
@hichamboushaba hichamboushaba deleted the issue/11508-coupons-card branch May 21, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: dashboard Related to home screen project type: enhancement A request for an enhancement. unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants