Skip to content

Today Widget - Fetch remote stats - #15391

Merged
Gio2018 merged 7 commits into
feature/ios-14-today-widgetfrom
feature/15347-today-widget-remote-stats
Nov 29, 2020
Merged

Today Widget - Fetch remote stats#15391
Gio2018 merged 7 commits into
feature/ios-14-today-widgetfrom
feature/15347-today-widget-remote-stats

Conversation

@Gio2018

@Gio2018 Gio2018 commented Nov 25, 2020

Copy link
Copy Markdown
Contributor

Fixes #15347

Notes:

  • in WordPressHomeWidgetToday there are two time constants:
    • refreshInterval: this is the refresh interval of the widget itself, set to 1 hour
    • minElapsedTimeToRefresh: this is the minimum elapsed time to request a refresh for a cached item. If, at the moment a cached element is read, it's older than this time, it will be re-fetched, otherwise it will be kept. This takes into account that a cached element can happen in several points. For example, if the app refreshes the cache after 58 minutes from the previous widget refresh, there is no need for the widget to make another network call when the hour passes.

To test:

  • Pre-requisites

    • to test this within reasonable amount of times, it's recommended to tweak refreshIntervalandminElapsedTimeToRefresh`.
      As an example, you could set:
      • refreshInterval = 5 (as far as I have seen, iOS would override smaller values anyway.)
      • minElapsedTimeToRefresh = 1
    • Use an account with a site that has some stats and to which you can update stats
  • Testing

    • On either simulator or device, build/run the app and install the widget (alternatively, you can build/run the widget scheme directly)
    • make sure the stats that you see in the widget are what you expect
    • update the stats of that site from another source (add comments likes etc from the web, another device/account etc)
    • wait a time that is at least the time you set for refreshInterval (keep in mind that iOS will decide when exactly to refresh the widget anyway), and make sure that the stats get updated in the widget

PR submission checklist:

  • I have considered adding unit tests where possible.
  • 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.

Giorgio Ruscigno added 6 commits November 20, 2020 10:42
- Also using TimeZone instead of TimeZoneName as the time zone property in HomeWidgetData
…y widget

- also add logic in WordPressHomeWidgetToday to only fetch remote stats if the cached values exist and are older than a given constant time
- store newly fetched data to local cache in getTimelineData, WordPressHomeWidgetToday
- fixed some naming in StatsInsightsStore, HomeWidgetTodayData, HomeWidgetCache
@Gio2018 Gio2018 added this to the 16.3 milestone Nov 25, 2020
@Gio2018 Gio2018 self-assigned this Nov 25, 2020
@peril-wordpress-mobile

peril-wordpress-mobile Bot commented Nov 25, 2020

Copy link
Copy Markdown

You can trigger an installable build for these changes by visiting CircleCI here.

@peril-wordpress-mobile

peril-wordpress-mobile Bot commented Nov 25, 2020

Copy link
Copy Markdown

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@Gio2018
Gio2018 marked this pull request as draft November 25, 2020 18:37
@Gio2018

Gio2018 commented Nov 25, 2020

Copy link
Copy Markdown
Contributor Author

@frosty @diegoreymendez please hold on this one, I have found a bug that needs fixing first. Sorry for the confusion!

@Gio2018
Gio2018 marked this pull request as ready for review November 25, 2020 21:06
@Gio2018

Gio2018 commented Nov 25, 2020

Copy link
Copy Markdown
Contributor Author

@diegoreymendez @frosty , this PR is back in the game!!

@frosty frosty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works great for me!

@diegoreymendez diegoreymendez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works really well for me. I haven't found anything to comment on the code, honestly... it looks rather clean to me and I really like that we're using the service.

@Gio2018

Gio2018 commented Nov 29, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing @diegoreymendez @frosty !!

@Gio2018
Gio2018 merged commit 3ae5e7d into feature/ios-14-today-widget Nov 29, 2020
@Gio2018
Gio2018 deleted the feature/15347-today-widget-remote-stats branch November 29, 2020 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants