Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75855

Don't allow duplicate conditions/filters to be added to a report

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.3
    • 4.1
    • Report builder
    • MOODLE_401_STABLE
    • MOODLE_403_STABLE
    • Hide

      Note: testing requires use of developer tools to capture requests, and a terminal to replay them

      Before checking out MDL-75855 branch

      1. Log in as admin
      2. Navigate to Reports from user menu
      3. Create new report from Users report source
        • Ensure Include default setup is checked
      4. Open browser developer tools
      5. Switch to Network tab
      6. In report editor, add User > Country condition
      7. Inspect the request to core_reportbuilder_conditions_add and copy the CURL command as below:
      8. Execute the command twice in a terminal
      9. Now repeat the process with the User > Country filter
      10. Execute the following in your database:

        SELECT MIN(id) AS id, reportid, uniqueidentifier, iscondition
        FROM mdl_reportbuilder_filter
        GROUP BY reportid, uniqueidentifier, iscondition
        HAVING COUNT(*) > 1
        

        • You should see two rows, one each for the user:country condition/filter (these are the duplicated entries)

      Check out the MDL-75855 branch

      1. Run/complete the upgrade
      2. Re-run the previous SQL query
      3. Confirm that it returns no results
      4. Navigate back to the report you previously created
      5. Open Conditions in the editor
      6. Confirm all previous conditions are still present (including User > Country)
      7. Open Filters in the editor
      8. Confirm all previous filters are still present (including User > Country)
      9. Re-run the previously copied curl command for adding the User > Country condition
      10. Confirm you receive back an exception with message "Duplicate condition"
      11. Re-run the previously copied curl command for adding the User > Country filter
      12. Confirm you receive back an exception with message "Duplicate filter"
      13. In report editor, add User > Phone condition
      14. Confirm condition was successfully added
      15. In report editor, add User > Phone filter
      16. Confirm filter was successfully added
      Show
      Note: testing requires use of developer tools to capture requests, and a terminal to replay them Before checking out MDL-75855 branch Log in as admin Navigate to Reports from user menu Create new report from Users report source Ensure Include default setup is checked Open browser developer tools Switch to Network tab In report editor, add User > Country condition Inspect the request to core_reportbuilder_conditions_add and copy the CURL command as below: Execute the command twice in a terminal Now repeat the process with the User > Country filter Execute the following in your database: SELECT MIN(id) AS id, reportid, uniqueidentifier, iscondition FROM mdl_reportbuilder_filter GROUP BY reportid, uniqueidentifier, iscondition HAVING COUNT(*) > 1 You should see two rows, one each for the user:country condition/filter (these are the duplicated entries) Check out the MDL-75855 branch Run/complete the upgrade Re-run the previous SQL query Confirm that it returns no results Navigate back to the report you previously created Open Conditions in the editor Confirm all previous conditions are still present (including User > Country ) Open Filters in the editor Confirm all previous filters are still present (including User > Country ) Re-run the previously copied curl command for adding the User > Country condition Confirm you receive back an exception with message "Duplicate condition" Re-run the previously copied curl command for adding the User > Country filter Confirm you receive back an exception with message "Duplicate filter" In report editor, add User > Phone condition Confirm condition was successfully added In report editor, add User > Phone filter Confirm filter was successfully added

      This was discovered by davidmatamoros in some unit tests: it's possible for duplicate conditions and/or filters to be added to a single report:

      It's typically not possible to re-create this through normal UI interactions, but can be done by replaying WS requests for managing report content. This is potentially confusing when it does happen, because having duplicate conditions/filters has no effect, and they will conflict with each other when trying to apply differing values to each (note you can have the same type of condition/filter added to a report, e.g. User > Email as both a condition and a filter, but you cannot have two User > Email conditions in the same report)

      We can prevent this by implementing checks in the API and adding constraints at the database level

        1. (I) Passed -- (Master)MDL-75855.png
          125 kB
          Kim Jared Lucas
        2. (II) 10 Passed -- (Master)MDL-75855.png
          93 kB
          Kim Jared Lucas
        3. (II) 12 Passed -- (Master)MDL-75855.png
          88 kB
          Kim Jared Lucas
        4. (II) 16 Passed -- (Master)MDL-75855.png
          61 kB
          Kim Jared Lucas
        5. (II) 3 Passed -- (Master)MDL-75855.png
          113 kB
          Kim Jared Lucas
        6. (II) 8-9 Passed -- (Master)MDL-75855.png
          142 kB
          Kim Jared Lucas
        7. Copy as CURL.png
          53 kB
          Paul Holden
        8. Duplicates.png
          20 kB
          Paul Holden

            pholden Paul Holden
            pholden Paul Holden
            Andrew Lyons Andrew Lyons
            David Carrillo David Carrillo
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 54 minutes
                3h 54m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.