<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<contentHaul xmlns:a="http://www.appian.com/ae/types/2009">
    <rule>
        <name>${interface_report_name}</name>
        <uuid>${interface_report_uuid}</uuid>
        <description>${interface_report_desc}</description>
        <parentUuid>${folder_rulesAndConstants}</parentUuid>
        <visibility>
            <advertise>false</advertise>
            <hierarchy>true</hierarchy>
            <indexable>true</indexable>
            <quota>false</quota>
            <searchable>true</searchable>
            <system>false</system>
            <unlogged>false</unlogged>
        </visibility>
        <definition>a!localVariables(
  /* Search terms and filters */
  local!searchTerm,
  local!creator,
  local!creationMonth,
  local!statusFilter,
  local!priorityFilter,
  local!pagingInfo: #&quot;SYSTEM_SYSRULES_pagingInfo&quot;(1, 50, #&quot;SYSTEM_SYSRULES_sortInfo&quot;(&quot;createdOn&quot;, false)),
  /* Data that will be displayed in the grid given the *
   * current search terms and applied filters          */
  local!datasubset: #&quot;SYSTEM_SYSRULES_queryEntity_v2&quot;(
    entity: #&quot;${cdt_mainDseConstant_uuid}&quot;,
    query: #&quot;SYSTEM_SYSRULES_query&quot;(
      selection: #&quot;SYSTEM_SYSRULES_querySelection&quot;(
        columns: {
${report_query_columns}
        }
      ),
      logicalExpression: #&quot;SYSTEM_SYSRULES_queryLogicalExpression&quot;(
        operator: &quot;AND&quot;,
        ignoreFiltersWithEmptyValues: true,
        logicalExpressions: #&quot;SYSTEM_SYSRULES_queryLogicalExpression&quot;(
          operator: &quot;OR&quot;,
          ignoreFiltersWithEmptyValues: true,
          filters: {
${report_search_filters}
          }
        ),
        filters: {
          #&quot;SYSTEM_SYSRULES_queryFilter&quot;(field: &quot;createdBy&quot;, operator: &quot;=&quot;, value: local!creator),
          if(
            isnull(local!creationMonth),
            null,
            #&quot;SYSTEM_SYSRULES_queryFilter&quot;(
              field: &quot;createdOn&quot;,
              operator: &quot;between&quot;,
              value: {
                todatetime(eomonth(today(), local!creationMonth-1)+1),
                todatetime(eomonth(today(), local!creationMonth)+1)
              }
            )
          ),
          ${report_queryFilter_status}
          ${report_queryFilter_priority}
        }
      ),
      pagingInfo: local!pagingInfo
    ),
    fetchTotalCount: true
  ),
  /* Data for the top creators chart. Returns the number *
   * of records entered by each of the top 5 users       */
  local!creatorDatasubset: #&quot;SYSTEM_SYSRULES_queryEntity_v2&quot;(
    entity: #&quot;${cdt_mainDseConstant_uuid}&quot;,
    query: #&quot;SYSTEM_SYSRULES_query&quot;(
      aggregation: #&quot;SYSTEM_SYSRULES_queryAggregation&quot;(
        aggregationColumns: {
          #&quot;SYSTEM_SYSRULES_queryAggregationColumn&quot;(field: &quot;createdBy&quot;, isGrouping: true),
          #&quot;SYSTEM_SYSRULES_queryAggregationColumn&quot;(field: &quot;id&quot;, aggregationFunction: &quot;COUNT&quot;),
        }
      ),
      pagingInfo: #&quot;SYSTEM_SYSRULES_pagingInfo&quot;(1, 5, #&quot;SYSTEM_SYSRULES_sortInfo&quot;(&quot;id&quot;, false))
    ),
    fetchTotalCount: false
  ),
  /* Raw data for the number of records by month chart.  *
   * Returns the creation date for each record so that   *
   * they can be grouped by month in a later step        */
  local!recordsbyMonthData: #&quot;SYSTEM_SYSRULES_queryEntity_v2&quot;(
    entity: #&quot;${cdt_mainDseConstant_uuid}&quot;,
    query: #&quot;SYSTEM_SYSRULES_query&quot;(
      aggregation: #&quot;SYSTEM_SYSRULES_queryAggregation&quot;(
        aggregationColumns: {
          #&quot;SYSTEM_SYSRULES_queryAggregationColumn&quot;(field: &quot;createdOn&quot;, alias: &quot;year&quot;, isGrouping: true, groupingFunction: &quot;YEAR&quot;),
          #&quot;SYSTEM_SYSRULES_queryAggregationColumn&quot;(field: &quot;createdOn&quot;, alias: &quot;month&quot;, isGrouping: true, groupingFunction: &quot;MONTH&quot;),
          #&quot;SYSTEM_SYSRULES_queryAggregationColumn&quot;(field: &quot;id&quot;, alias: &quot;count&quot;, aggregationFunction: &quot;COUNT&quot;)
        }
      ),
      pagingInfo: #&quot;SYSTEM_SYSRULES_pagingInfo&quot;(
        startIndex: 1,
        batchSize: -1,
        sort: {
          #&quot;SYSTEM_SYSRULES_sortInfo&quot;(&quot;year&quot;, true),
          #&quot;SYSTEM_SYSRULES_sortInfo&quot;(&quot;month&quot;, true)
        }
      )
    ),
    fetchTotalCount: false
  ).data,
  local!allMonths: a!flatten(
    a!forEach(
      /* Returns a list of years from the first year in the data set to now */
      items: if(
        or(isnull(local!recordsbyMonthData), length(local!recordsbyMonthData)=0),
        {},
        enumerate(
          tointeger(local!recordsByMonthData[length(local!recordsByMonthData)].year)
          - tointeger(local!recordsByMonthData[1].year) + 1
        ) + tointeger(local!recordsByMonthData[1].year)
      ),
      expression: a!localVariables(
        local!year: fv!item,
        /* Start and end are the first and last months in the given year, */
        /*to make sure we don't go past today or before the first data point. */
        local!start: if(
          fv!isFirst,
          tointeger(local!recordsByMonthData[1].month),
          1
        ),
        local!end: if(
          fv!isLast,
          tointeger(local!recordsByMonthData[length(local!recordsByMonthData)].month),
          12
        ),
        /* Uses start and end to enumerate the months in the given year. */
        a!forEach(
          items: enumerate(local!end - local!start + 1) + local!start,
          expression: {
            month: fv!item,
            year: local!year
          }
        )
      )
    )
  ),
  ${report_datasubset_status}
  ${report_datasubset_priority}
  {
    if(
      and(
        local!datasubset.totalCount = 0,
        isnull(local!searchTerm),
        isnull(local!creator),
        isnull(local!creationMonth),
        isnull(local!statusFilter),
        isnull(local!priorityFilter)
      ),
      #&quot;SYSTEM_SYSRULES_richTextDisplayField&quot;(
        labelPosition: &quot;COLLAPSED&quot;,
        align: &quot;CENTER&quot;,
        value: {
          #&quot;SYSTEM_SYSRULES_richTextHeader&quot;(
            text: ${report_empty_chart_title},
            size: &quot;MEDIUM&quot;
          ),
          #&quot;SYSTEM_SYSRULES_richTextItem_v1&quot;(
            text: &quot;${report_empty_chart_message}&quot;
          )
        }
      ),
      {
        #&quot;SYSTEM_SYSRULES_sectionLayout_v1&quot;(
          label: &quot;${report_statistics_label}&quot;,
          contents: a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  #&quot;SYSTEM_SYSRULES_columnChartField&quot;(
                    label: &quot;${report_filter_topCreators_label}&quot;,
                    showLegend: false,
                    categories: if(
                      count(local!creatorDatasubset.data) = 0,
                      {},
                      a!forEach(
                        items: index(local!creatorDatasubset.data, &quot;createdBy&quot;, null),
                        expression: #&quot;${expRule_formatName_uuid}&quot;(fv!item)
                      )
                    ),
                    series: #&quot;SYSTEM_SYSRULES_chartSeries&quot;(
                      label: &quot;${report_created_label}&quot;,
                      data: index(local!creatorDatasubset.data, &quot;id&quot;, null),
                      links: if(
                        count(local!creatorDatasubset.data) = 0,
                        {},
                        a!forEach(
                          items: index(local!creatorDatasubset.data, &quot;createdBy&quot;, null),
                          expression: #&quot;SYSTEM_SYSRULES_dynamicLink&quot;(
                            value: fv!item,
                            saveInto: {
                              local!creator,
                              a!save(local!pagingInfo.startIndex, 1)
                            }
                          )
                        )
                      )
                    )
                  ),
                  #&quot;SYSTEM_SYSRULES_lineChartField_v1&quot;(
                    label: &quot;${report_filter_recentByMonth_label}&quot;,
                    categories: a!forEach(
                      items: local!allMonths,
                      expression: text(
                        date(
                          index(local!allMonths, &quot;year&quot;, null)[fv!index],
                          index(local!allMonths, &quot;month&quot;, null)[fv!index],
                          1
                        ),
                        &quot;mmmm yyyy&quot;
                      )
                    ),
                    showLegend: false,
                    connectNulls: true,
                    series: #&quot;SYSTEM_SYSRULES_chartSeries&quot;(
                      label: &quot;Test Count&quot;,
                      data: a!forEach(
                        items: local!allMonths,
                        expression: a!localVariables(
                          local!dataInThisYear: index(
                            local!recordsbyMonthData,
                            wherecontains(fv!item.year, local!recordsbyMonthData.year),
                            {}
                          ),
                          local!value: index(
                            local!dataInThisYear,
                            wherecontains(fv!item.month, local!dataInThisYear.month),
                            {}
                          ),
                          /* Set nulls if there is no value for a data point */
                          if(
                            length(local!value) &lt; 1,
                            null,
                            local!value[1].count
                          )
                        )
                      )
                    )
                  )
                }
              ),
              a!columnLayout(
                contents: {
${report_chartField_status}${report_chartField_priority}
                }
              )
            }
          )
        ),
        #&quot;SYSTEM_SYSRULES_sectionLayout_v1&quot;(
          label: &quot;${report_details_label}&quot;,
          contents: a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  #&quot;SYSTEM_SYSRULES_textField&quot;(
                    labelPosition: &quot;COLLAPSED&quot;,
                    placeholder: &quot;${report_search_record_fields}&quot;,
                    value: local!searchTerm,
                    saveInto: {
                      local!searchTerm,
                      a!save(local!pagingInfo.startIndex, 1)
                    },
                    refreshAfter: &quot;KEYPRESS&quot;
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  #&quot;${interface_gridFilters_uuid}&quot;(
                    creator: local!creator,
                    creationTime: local!creationMonth,
                    status: local!statusFilter,
                    priority: local!priorityFilter,
                    searchTerm: local!searchTerm,
                    pagingInfo: local!pagingInfo
                  )
                }
              )
            }
          )
        ),
        #&quot;SYSTEM_SYSRULES_sectionLayout_v1&quot;(
          contents: {
            #&quot;SYSTEM_SYSRULES_gridField_v3&quot;(
              height: &quot;MEDIUM&quot;,
              rowHeader: 1,
              emptyGridMessage: &quot;${report_empty_grid_message}&quot;,
              data: local!datasubset,
              columns: {
${report_grid_columns}
              },
              /* We check for a null sort field, and ignore the save if it is null. *
                * This would most likely happen by a user clicking on a multi-select *
                * column, which does not have a sort field defined. Since that click *
                * would only set a single sort, we index into the first sort field. */
              pagingSaveInto: {
                a!save(
                  local!pagingInfo,
                  if(
                    /* We check specifically if the whole sort is null because the grid *
                      * will null out the sort if it is paged while the sort field is not *
                      * represented in the grid. */
                    or(
                      isnull(index(save!value.sort, 1, null)),
                      not(isnull(index(index(save!value.sort, 1, null), "field", null)))
                    ),
                    save!value,
                    local!pagingInfo
                  )
                )
              }
            )
          }
        )
      }
    )
  }
)</definition>
        <preferredEditor>interface</preferredEditor>
        <offlineEnabled>false</offlineEnabled>
    </rule>
    <roleMap public="true">
        <role allowForAll="false" inherit="true" name="readers">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="true" name="authors">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="true" name="administrators">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="false" name="denyReaders">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="false" name="denyAuthors">
            <users/>
            <groups/>
        </role>
        <role allowForAll="false" inherit="false" name="denyAdministrators">
            <users/>
            <groups/>
        </role>
    </roleMap>
    <typedValue>
        <type>
            <name>RuleTestConfig?list</name>
            <namespace>http://www.appian.com/ae/types/2009</namespace>
        </type>
        <value>
            <el>
                <a:name/>
                <a:assertions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
            </el>
        </value>
    </typedValue>
</contentHaul>
