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

Add display of visit counts and conditionally style them (UHC mode) #4758

Closed
amandacilek-zz opened this issue Jul 26, 2018 · 5 comments
Closed
Assignees
Labels
Priority: 2 - Medium Normal priority Type: Feature Add something new

Comments

@amandacilek-zz
Copy link

amandacilek-zz commented Jul 26, 2018

For UHC mode, we already display "Date last visited". We would like to keep that, and add in a visual display of "Number of visits this month".

Clarification
Although they sound similar, “Date last visited” and “Visits this month” are two completely different data points. Date last visited is calculated based upon a rolling count of “how many days ago” and is not tied to the calendar at all. Visits this month is tied directly to the calendar month. Date last visited never resets while visits this month resets back to 0 at the beginning of each month.

Visits this month
We would like to add large visit count numbers to the right side of each family row. The visit count will display a count of the number of times that family has been visited so far within the current month. The exact definition of the calendar month should be left configurable. Some partners may follow the calendar literally, while other partners have different definitions of a month (ex: Muso counts from the 26th of one month until the 25th of the next month). Whatever forms have been configured to calculate "Date last visited" will be the same forms used to calculate "Visits this month".

Basic layout

  • The count can be "0", "1", "2", "3", "4" visits etc. Two digits should be allowed (but probably not common). After two digits (highly unlikely) we should display a summary such as "99+".
  • The count number is located in the upper right of the row and sits on the same baseline as the contact name text. Noto Sans, bold, 24px (H1).
  • The word "visit(s)" is below the count number and sits on the same baseline as the date last visited text. Noto Sans, bold, 14px.
  • Both the visit count and the word "visit(s)" are right-aligned (meaning any extra characters push the word to the left). The far right edge of both text boxes is aligned. There is a 10px gap between the far right edge of the text boxes and the right edge of the screen.
  • Both the number digit and the word "visit(s)" should be internationalized so various language translations and scripts can be configured

markup

Conditional styling

  • We would like to give partners the ability to conditionally style the counts, or not
  • If the partner has no specific goals, just like with Targets, the text is normal black
  • If the partner does have specific goals, we use red to indicate "bad", yellow to indicate "ok" and green to indicate "good" or "goal met". Red = # E33030, Yellow = # C38813, Green = # 538E8D.
  • Adding to this, we can also, optionally, display an icon next to the count number. This icon is only available as an option if the partner has a goal. If the partner does not have a goal there will never be an icon. The icon is FontAwesome fa-exclamation-triangle [ & # x f 0 7 1 ; ]. Size 16px, color # E33030.
  • The icon is positioned to the left of the count number on the same baseline.
  • Note: We would like to remove the red warning icon by the date last visited text that we implemented in 2.16.1. The new functionality and location of the icon as described here replaces what we did in 2.16.1. It used to be tied to date last visited - now it is instead tied to visits this month.

screen shot 2018-07-26 at 2 18 36 pm

Muso's desired configuration

  • The text of the counts should be red if the count is “0”, yellow if “1” and green if 2 or more.
  • If the count is "0" or "1" it should also be accompanied by a red warning icon.

Here is what the visit counts will always look like at the very beginning of the month ("0 visits" for every single family):
beginning of month

Here is what the visit counts should look like after three visits have been made:
after first week copy

And here is what the visit counts might look like even later in the month:
after second week copy

Another clarification
You will notice that it is sometimes possible for families with 2 visits to appear above families with 1 visit in the list, due to the sorting based upon “Date last visited”. We are aware of this outcome but think it makes sense in light of the emphasis on frequency of home visits. It is possible we might get a request in down the road to add the ability to sort "By number of visits this month" but that is an issue for another time.

@SCdF
Copy link
Contributor

SCdF commented Jul 27, 2018

Update: I have deleted my above comments (in case you wonder where they went, because they are no longer true or relevant to the discussion.

I've talked to the CouchDB folks, and reduce functions are partially run at index time and stored (for performance reasons), so:

  • We can't have a reduce with any dynamic time-based logic in there, because it doesn't all run when you query, so a reduce function that only counts reports based on "this month" cannot work
  • We shouldn't upload reduce functions dynamically because they would cause the entire view to re-generate, due to the data structures used by Couch.

In case it's not obvious, this invalidates the reduce function I wrote in the product call earlier this week, because it relied on the code being run completely dynamically every time you requested it.

OK to that leaves us with two real options for this ticket:

  • Keep the contacts_by_last_visited_date view as it is, but no longer reduce on the server side, instead downloading all of the view results locally and "reducing" there. Big downside of this is that you cannot filter by a list of contacts and also filter by date, so you need to download as many entries as your contacts have ever had visits, every time you render or re-render this page.
  • Changing the contacts_by_last_visited_date view, or using some existing / new view, that has a composite key of contactId and lastReportedDate, and run N view calls, one for each contact that you care about, with [contactId, minimumDateAsWorkedOutFromConfiguration], and then run a _reduce on that.

The former is almost certainly the best approach, the latter invoking way more IO than the former (though neither are ideal).

If this was 3.0.0 we could consider a Mango query, but 2.18 will not have support for them.

@dianabarsan dianabarsan self-assigned this Jul 30, 2018
dianabarsan added a commit that referenced this issue Aug 15, 2018
Adds visit count display in contacts list. Visit count display is conditioned by the same permission as displaying last visited date. Visits are counted based on the calendar month, with each month starting on either the 1st or on a configurable date. Visit counters may be color coded if a specific visit count goal configured.

Adds UHC app configuration section.
Adds UHC configuration with options to select default sorting contacts lists by last visited date, visit counter settings for monthly count goal and the month reset/start date.

#4758
#4752
dianabarsan added a commit that referenced this issue Aug 15, 2018
Adds visit count display in contacts list. Visit count display is
conditioned by the same permission as displaying last visited date.
Visits are counted based on the calendar month, with each month
starting on either the 1st or on a configurable date. Visit counters
may be color coded if a specific visit count goal configured.

Adds UHC app configuration section.
Adds UHC configuration with options to select default sorting contacts
lists by last visited date, visit counter settings for monthly count
goal and the month reset/start date.

#4758
#4752
dianabarsan added a commit that referenced this issue Aug 15, 2018
Adds visit count display in contacts list. Visit count display is
conditioned by the same permission as displaying last visited date.
Visits are counted based on the calendar month, with each month
starting on either the 1st or on a configurable date. Visit counters
may be color coded if a specific visit count goal configured.

Adds UHC app configuration section.
Adds UHC configuration with options to select default sorting contacts
lists by last visited date, visit counter settings for monthly count
goal and the month reset/start date.

#4758
#4752
@dianabarsan dianabarsan removed their assignment Aug 15, 2018
@dianabarsan
Copy link
Member

Merged into 2.18 and forward ported to 3.0.x and master.

@ngaruko ngaruko self-assigned this Aug 21, 2018
@dianabarsan
Copy link
Member

dianabarsan commented Aug 27, 2018

To enable the specific goal (which color codes the number of visits), you need to configure it in app_settings. Add the following section:

"uhc": {
    "contacts_default_sort": "",
    "visit_count": {
        "month_start_date": 1,
        "visit_count_goal": 0
     }
}

where:

Setting Default Accepted values Description
contacts_default_sort empty string * last_visited_date: default contact sorting will be based on last visited date.
*: default contact sorting will be alphabetical
visit_count / month_start_date 1 1-31 Designates the monthly date when the visit count is reset.
visit_count / visit_count_goal 0 integer >= 0 Designates the monthly visit count goal.

@ngaruko
Copy link
Contributor

ngaruko commented Aug 27, 2018

Thanks @dianabarsan for comments above. LGTM.
Tested on beta-old.dev with 2.18
image

@garethbowen
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 2 - Medium Normal priority Type: Feature Add something new
Projects
None yet
Development

No branches or pull requests

5 participants