diff --git a/firebase/admin/firestore.indexes.json b/firebase/admin/firestore.indexes.json index c24b07fac..60b0f6239 100644 --- a/firebase/admin/firestore.indexes.json +++ b/firebase/admin/firestore.indexes.json @@ -3030,6 +3030,20 @@ } ] }, + { + "collectionGroup": "classes", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "districtId", + "order": "ASCENDING" + }, + { + "fieldPath": "lastRoarSync", + "order": "ASCENDING" + } + ] + }, { "collectionGroup": "districts", "queryScope": "COLLECTION", @@ -3180,6 +3194,20 @@ } ] }, + { + "collectionGroup": "schools", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "districtId", + "order": "ASCENDING" + }, + { + "fieldPath": "lastRoarSync", + "order": "ASCENDING" + } + ] + }, { "collectionGroup": "users", "queryScope": "COLLECTION", @@ -3426,6 +3454,20 @@ } ] }, + { + "collectionGroup": "users", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "districts.current", + "arrayConfig": "CONTAINS" + }, + { + "fieldPath": "archived", + "order": "ASCENDING" + } + ] + }, { "collectionGroup": "users", "queryScope": "COLLECTION", diff --git a/src/components/ListUsers.vue b/src/components/ListUsers.vue index f5fad91bd..98f4b20ea 100644 --- a/src/components/ListUsers.vue +++ b/src/components/ListUsers.vue @@ -222,6 +222,12 @@ const columns = ref([ dataType: 'string', sort: false, }, + { + field: 'archived', + header: 'Archived', + dataType: 'boolean', + sort: false, + }, { header: 'Edit', button: true, diff --git a/src/helpers/query/assignments.js b/src/helpers/query/assignments.js index 94532b2f3..2c36a7edd 100644 --- a/src/helpers/query/assignments.js +++ b/src/helpers/query/assignments.js @@ -173,97 +173,6 @@ export const getAssignmentsRequestBody = ({ return requestBody; }; -export const getUsersByAssignmentIdRequestBody = ({ - adminId, - orgType, - orgId, - filter, - aggregationQuery, - pageLimit, - page, - paginate = true, - select = userSelectFields, -}) => { - const requestBody = { - structuredQuery: {}, - }; - - if (!aggregationQuery) { - if (paginate) { - requestBody.structuredQuery.limit = pageLimit; - requestBody.structuredQuery.offset = page * pageLimit; - } - - if (select.length > 0) { - requestBody.structuredQuery.select = { - fields: select.map((field) => ({ fieldPath: field })), - }; - } - } - - requestBody.structuredQuery.from = [ - { - collectionId: 'users', - allDescendants: false, - }, - ]; - - requestBody.structuredQuery.where = { - compositeFilter: { - op: 'AND', - filters: [ - { - fieldFilter: { - field: { fieldPath: `${pluralizeFirestoreCollection(orgType)}.current` }, - op: 'ARRAY_CONTAINS', - value: { stringValue: orgId }, - }, - }, - { - fieldFilter: { - field: { fieldPath: 'assignments.assigned' }, - op: 'ARRAY_CONTAINS_ANY', - value: { arrayValue: { values: [{ stringValue: adminId }] } }, - }, - }, - { - fieldFilter: { - field: { fieldPath: 'archived' }, - op: 'EQUAL', - value: { booleanValue: false }, - }, - }, - ], - }, - }; - - if (filter) { - requestBody.structuredQuery.where.compositeFilter.filters.push({ - fieldFilter: { - field: { fieldPath: filter[0].field }, - op: 'EQUAL', - value: { stringValue: filter[0].value }, - }, - }); - } - - if (aggregationQuery) { - return { - structuredAggregationQuery: { - ...requestBody, - aggregations: [ - { - alias: 'count', - count: {}, - }, - ], - }, - }; - } - - return requestBody; -}; - export const getFilteredScoresRequestBody = ({ adminId, orgId, diff --git a/src/helpers/query/users.js b/src/helpers/query/users.js index 53da1e74f..1e7e8fb0e 100644 --- a/src/helpers/query/users.js +++ b/src/helpers/query/users.js @@ -10,6 +10,7 @@ export const getUsersRequestBody = ({ paginate = true, select = ['name'], orderBy, + restrictToActiveUsers = false, }) => { const requestBody = { structuredQuery: {}, @@ -39,18 +40,20 @@ export const getUsersRequestBody = ({ requestBody.structuredQuery.where = { compositeFilter: { op: 'AND', - filters: [ - { - fieldFilter: { - field: { fieldPath: 'archived' }, - op: 'EQUAL', - value: { booleanValue: false }, - }, - }, - ], + filters: [], }, }; + if (restrictToActiveUsers) { + requestBody.structuredQuery.where.compositeFilter.filters.push({ + fieldFilter: { + field: { fieldPath: 'archived' }, + op: 'EQUAL', + value: { booleanValue: false }, + }, + }); + } + if (userIds.length > 0) { requestBody.structuredQuery.where.compositeFilter.filters.push({ fieldFilter: { @@ -96,21 +99,7 @@ export const getUsersRequestBody = ({ return requestBody; }; -export const usersPageFetcher = async (userIds, pageLimit, page) => { - const axiosInstance = getAxiosInstance(); - const requestBody = getUsersRequestBody({ - userIds, - aggregationQuery: false, - pageLimit: pageLimit.value, - page: page.value, - paginate: true, - }); - - console.log(`Fetching page ${page.value} for ${userIds}`); - return axiosInstance.post(':runQuery', requestBody).then(({ data }) => mapFields(data)); -}; - -export const fetchUsersByOrg = async (orgType, orgId, pageLimit, page, orderBy) => { +export const fetchUsersByOrg = async (orgType, orgId, pageLimit, page, orderBy, restrictToActiveUsers = false) => { const axiosInstance = getAxiosInstance(); const requestBody = getUsersRequestBody({ orgType, @@ -119,15 +108,16 @@ export const fetchUsersByOrg = async (orgType, orgId, pageLimit, page, orderBy) pageLimit: pageLimit.value, page: page.value, paginate: true, - select: ['username', 'name', 'studentData', 'userType'], + select: ['username', 'name', 'studentData', 'userType', 'archived'], orderBy: orderBy.value, + restrictToActiveUsers: restrictToActiveUsers, }); console.log(`Fetching users page ${page.value} for ${orgType} ${orgId}`); return axiosInstance.post(':runQuery', requestBody).then(({ data }) => mapFields(data)); }; -export const countUsersByOrg = async (orgType, orgId, orderBy) => { +export const countUsersByOrg = async (orgType, orgId, orderBy, restrictToActiveUsers = false) => { const axiosInstance = getAxiosInstance(); const requestBody = getUsersRequestBody({ orgType, @@ -135,6 +125,7 @@ export const countUsersByOrg = async (orgType, orgId, orderBy) => { aggregationQuery: true, paginate: false, orderBy: orderBy.value, + restrictToActiveUsers: restrictToActiveUsers, }); return axiosInstance.post(':runAggregationQuery', requestBody).then(({ data }) => { diff --git a/src/pages/SignIn.vue b/src/pages/SignIn.vue index ae4baa395..ed4d78f6c 100644 --- a/src/pages/SignIn.vue +++ b/src/pages/SignIn.vue @@ -213,7 +213,7 @@ const modalPassword = ref(''); const authWithClever = () => { console.log('---> authWithClever'); - authStore.signInWithCleverRedirect(); + authStore.signInWithCleverPopup(); spinner.value = true; // } }; @@ -225,7 +225,6 @@ const authWithClassLink = () => { spinner.value = true; } else { authStore.signInWithClassLinkRedirect(); - // authStore.signInWithCleverPopup(); spinner.value = true; } };