hypothesis / lms

LTI app for integrating with learning management systems
BSD 2-Clause "Simplified" License
45 stars 14 forks source link

Generate organization usage stats from LMS #6159

Open marcospri opened 3 months ago

marcospri commented 3 months ago

Current situation

The report system is not prepared to deal with arbitrary contract dates and modifying that would be a fundamental architecture change.

As a stop gap measure we allow now to generate usage reports for an org between two any arbitrary dates. It's up to the user of the admin pages now to use the adecute dates here and copy over the information to HubSpot.

Proposal for next version

An organization might have multiple deals, current and past, we'll store all of them in the DB fetching them from HS every day/week.

Based on the contract dates generate monthly reports for ongoing deals.

This usage reports do take into account sub-organizations. Generating the report for all organizations guarantees we have the data for both the parent orgs and their children.

Generating the reports is an expensive operation so we should rate limit the process. If this is a monthly process it shouldn't be a problem that, worst case scenario, all the report takes a couple of days to be generated.

Store both the count and the actual report (ie a list of rows) in the DB. Having the counts will allow to create graphs comparing deals/dates/periods trivially in metabase. Storing the full report allow to fetch them repeatedly without the cost of generating it.

Once the reports are generated write the result (just the count of unique users) in HS.

dwhly commented 3 months ago

PRD: https://docs.google.com/document/d/1jjqALVaqkLsN4Qfz0MhW7HOKV_TswU0VYk66gwVavVo/edit#heading=h.6ivhz3247mk9

marcospri commented 2 months ago

Related: https://github.com/hypothesis/product-backlog/issues/1536

marcospri commented 1 month ago

There's now reports generated with the new process this can be accessed from this report:

Little demo:

https://github.com/hypothesis/lms/assets/1433832/131d02c4-1e22-41f3-a19c-62c6fc7e06ed

What left for this to be closed:

Known issues:

What I have not done in this stream of work: