kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Implement new `KDateRange` component in log export

Open bjester opened this issue 3 years ago • 2 comments

Depends on https://github.com/learningequality/kolibri/issues/9704 and https://github.com/learningequality/kolibri-design-system/issues/360

Observed behavior

  • Current behavior generates a log for all-time when Generate log is clicked
  • The current file names follow the pattern:
    • {facility_name}_{last 4 digits of facility ID}_{log export type}.csv
    • Example:

Expected behavior

  • When Generate log is clicked it should open the date range selection with KDateRange component
  • A new database model should exist for storing the user's log generation request:
    • It should have a UUID field for uniquely storing and identifying the generated log file in the filesystem
    • It should store the start and end dates the user selected
  • When the user confirms their date selection, it should generate a new database model
  • The new exported filename generated during download should follow:
    • {facility_name}_{last 4 digits of facility ID}_{log export type}_from_{start date}_to_{end date}.csv
    • from {date} to {date} should be localized in the user's language
    • Examples:
      • end date is before current month (e.g 9/2022): MyFacility_abcd_content_summary_logs_from_2022-01-01_to_2022-08-31.csv
      • end date includes current month: MyFacility_abcd_content_summary_logs_from_2022-01-01_to_2022-09-09.csv

bjester avatar Sep 09 '22 17:09 bjester

Thinking through the logic for the 2 export date selection states, if I selected Sept 2022 as the last end date for my export, during that same month (like we are currently), would it make sense to default the next export's start date to Sept 2022 since the last export contained the incomplete month of Sept 2022? I think this is where mention of the inclusive nature of the dates might make sense.

Alternatively, if I last selected an end date of Aug 2022 while the current date was afterwards, e.g. Sept 2022, then the next export's default start would be Sept 2022.

Also, I'm thinking that when we capture the dates in the exported file name, we should include the day date. So if they selected the end date to be the same as the current month, it would be something like

MyFacility_abcd_content_summary_logs_from_2022-01-01_to_2022-09-22.csv

and alternatively

MyFacility_abcd_content_summary_logs_from_2022-01-01_to_2022-08-31.csv

(today is 2022-09-22)

bjester avatar Sep 22 '22 14:09 bjester

One other caveat to be aware of here, is to make sure to use the serverClock utilities, to ensure that we are using date and time as reckoned by the server device, and not the client (as they can sometimes be fairly different if there have been power issues on either side!):

import { now } from 'kolibri.utils.serverClock';

See examples in the codebase here: https://github.com/learningequality/kolibri/search?q=serverclock

rtibbles avatar Sep 22 '22 14:09 rtibbles