Skip to content

Commit ce4e8df

Browse files
committed
Implement an endpoint to check submissions for which action is required, and send a discord update
1 parent 41c9253 commit ce4e8df

File tree

4 files changed

+132
-19
lines changed

4 files changed

+132
-19
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { Submission } from "../../services";
22
import { generateBaseRootResolvers } from "../../core/helpers/rootResolver";
3+
import { GiraffeqlRootResolverType } from "giraffeql";
4+
import { Scalars } from "../..";
35

46
export default {
57
...generateBaseRootResolvers({
68
service: Submission,
79
methods: ["get", "getMultiple", "delete", "create", "update"],
810
restMethods: ["get", "getMultiple"],
911
}),
12+
13+
checkSubmissions: new GiraffeqlRootResolverType({
14+
name: "checkSubmissions",
15+
type: Scalars.number,
16+
allowNull: false,
17+
resolver: (inputs) => Submission.checkSubmissions(inputs),
18+
}),
1019
};

backend/functions/src/schema/models/submission/service.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
} from "../../helpers/common";
3737
import { objectOnlyHasFields } from "../../core/helpers/shared";
3838
import { GiraffeqlBaseError } from "giraffeql";
39+
import { env } from "../../../config";
3940

4041
type UpdateLogPostSubmission = {
4142
submission: any;
@@ -256,6 +257,57 @@ export class SubmissionService extends PaginatedService {
256257
}
257258
}
258259

260+
// goes through all submissions that are info requested, submitted, or under review and returns the count. also sends an update in discord subAlerts channel.
261+
async checkSubmissions({
262+
req,
263+
fieldPath,
264+
args,
265+
query,
266+
isAdmin = false,
267+
}: ServiceFunctionInputs) {
268+
const recordsCount = await this.countSqlRecord({
269+
where: [
270+
{
271+
field: "status",
272+
operator: "in",
273+
value: [
274+
submissionStatusKenum.INFORMATION_REQUESTED.index,
275+
submissionStatusKenum.SUBMITTED.index,
276+
submissionStatusKenum.UNDER_REVIEW.index,
277+
],
278+
},
279+
],
280+
});
281+
282+
if (recordsCount > 0) {
283+
await sendDiscordMessage(channelMap.subAlerts, {
284+
content: `${recordsCount} submissions - action required`,
285+
/* embeds: [
286+
{
287+
title: `Submission ID ${submissionId}`,
288+
description: await this.generateSubmissionText(submissionId),
289+
color: submissionStatusObject.colorId,
290+
},
291+
], */
292+
components: [
293+
{
294+
type: 1,
295+
components: [
296+
{
297+
type: 2,
298+
label: "View Submissions",
299+
style: 5,
300+
url: `${env.site.base_url}/review-queue`,
301+
},
302+
],
303+
},
304+
],
305+
});
306+
}
307+
308+
return recordsCount;
309+
}
310+
259311
@permissionsCheck("create")
260312
async createRecord({
261313
req,

frontend/components/navigation/navDrawer.vue

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
:to="item.to"
9494
nuxt
9595
router
96-
exact
96+
exact-path
9797
>
9898
<v-list-item-action>
9999
<v-icon>{{ item.icon }}</v-icon>
@@ -225,24 +225,7 @@ export default {
225225
{
226226
icon: 'mdi-format-list-checkbox',
227227
title: 'Review Queue',
228-
to: generateCrudRecordRoute(this, {
229-
typename: 'submission',
230-
routeType: 'a',
231-
pageOptions: {
232-
search: '',
233-
filters: [
234-
{
235-
field: 'status',
236-
operator: 'in',
237-
value: ['UNDER_REVIEW', 'SUBMITTED', 'INFORMATION_REQUESTED'],
238-
},
239-
],
240-
sort: {
241-
field: 'createdAt',
242-
desc: true,
243-
},
244-
},
245-
}),
228+
to: '/review-queue',
246229
},
247230
{
248231
icon: 'mdi-checkbox-marked',

frontend/pages/review-queue.vue

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<template>
2+
<div v-if="$route.query.pageOptions">
3+
<CrudRecordPage
4+
:record-info="recordInfo"
5+
:locked-filters="lockedFilters"
6+
:hidden-filters="hiddenFilters"
7+
icon="mdi-star"
8+
></CrudRecordPage>
9+
</div>
10+
<v-container v-else fluid fill-height justify-center>
11+
<v-progress-circular indeterminate></v-progress-circular>
12+
</v-container>
13+
</template>
14+
15+
<script>
16+
import { generateCrudRecordRoute } from '~/services/base'
17+
import CrudRecordPage from '~/components/page/crudRecordPage.vue'
18+
import { Submission } from '~/models/base'
19+
20+
export default {
21+
components: {
22+
CrudRecordPage,
23+
},
24+
25+
data() {
26+
return {
27+
recordInfo: Submission,
28+
}
29+
},
30+
31+
computed: {
32+
defaultRoute() {
33+
return generateCrudRecordRoute(this, {
34+
path: this.$route.path,
35+
pageOptions: {
36+
search: '',
37+
filters: [
38+
{
39+
field: 'status',
40+
operator: 'in',
41+
value: ['UNDER_REVIEW', 'SUBMITTED', 'INFORMATION_REQUESTED'],
42+
},
43+
],
44+
sort: {
45+
field: 'createdAt',
46+
desc: true,
47+
},
48+
},
49+
})
50+
},
51+
},
52+
53+
watch: {
54+
'$route.query.pageOptions'(val) {
55+
// if no pageOptions, automatically redirect
56+
if (!val) {
57+
this.$router.push(this.defaultRoute)
58+
}
59+
},
60+
},
61+
62+
mounted() {
63+
// if no pageOptions, automatically redirect
64+
if (!this.$route.query.pageOptions) {
65+
this.$router.push(this.defaultRoute)
66+
}
67+
},
68+
}
69+
</script>

0 commit comments

Comments
 (0)