Skip to content

Commit

Permalink
Feature: add tags (#1087)
Browse files Browse the repository at this point in the history
* add tag, translation, coursetag

* added crud to tags and translations

* add some tag tests; reshuffling some test stuff

* add tag types; tag resolver logic; create validate plugin

* some tag tests; some cleaning up

* snapshot fixing, jest utilities

* update eslint

* revert to downloading codecov uploader

* add missing prettier plugin to backend; nexus schema needs it

* add missing prettier plugin to backend; nexus schema needs it

* try moving import order plugin from dev deps to see if it helps

* remove import sort plugin from backend dev

* don't explicitly require the import sort plugin, should find if it is there

* link prettierrc to backend

* disable schema prettier for now
  • Loading branch information
mipyykko committed Jan 20, 2023
1 parent 3723ec2 commit 0eaff72
Show file tree
Hide file tree
Showing 141 changed files with 11,899 additions and 5,640 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: 2.1
orbs:
helm: circleci/helm@1.1.2
helm: circleci/helm@2.0.1
docker: circleci/[email protected]
jq: circleci/[email protected]
node: circleci/[email protected]
node: circleci/[email protected]
# codecov: codecov/[email protected]
executors:
backend_test:
docker:
Expand Down Expand Up @@ -132,10 +133,10 @@ jobs:
command: |
curl https://uploader.codecov.io/latest/linux/codecov -o /tmp/codecov
chmod +x /tmp/codecov
/tmp/codecov -F backend
#- run:
# name: "Upload coverage"
# command: bash <(curl -s https://codecov.io/bash)
/tmp/codecov -F backend -n "${CIRCLE_BUILD_NUM}"
### when codecov orb is enabled
# - codecov/upload:
# flags: backend
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large
# could combine the artifacts in this step if needed, now the codecov/junit stuff combines automatically
Expand Down Expand Up @@ -255,7 +256,6 @@ jobs:
resource_class: large

workflows:
version: 2
build-deploy:
jobs:
- code_style
Expand Down Expand Up @@ -291,4 +291,4 @@ workflows:
branches:
only:
- master
- staging
- staging
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const esLintConfig = {
"plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking", // these are a bit too strict for now
"plugin:jsx-a11y/recommended",
"prettier",
"plugin:@next/next/recommended",
"plugin:@next/next/core-web-vitals",
],
settings: {
react: {
Expand Down
4 changes: 3 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check
/** @type {import("@ianvs/prettier-plugin-sort-imports").PrettierConfig} */
module.exports = {
printWidth: 80,
semi: false,
Expand All @@ -15,7 +17,7 @@ module.exports = {
"",
"^/graphql",
],
plugins: [require.resolve("@ianvs/prettier-plugin-sort-imports")],
// plugins: [require.resolve("@ianvs/prettier-plugin-sort-imports")],
importOrderBuiltinModulesToTop: true,
importOrderSortSpecifiers: true,
importOrderCaseInsensitive: true,
Expand Down
1 change: 1 addition & 0 deletions backend/.prettierrc.js
50 changes: 26 additions & 24 deletions backend/api/routes/__test__/__snapshots__/completions.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`API /api/register-completions creates registered completions 1`] = `
Array [
Object {
"completion_id": "30000000-0000-0000-0000-000000000102",
"course_id": "00000000-0000-0000-0000-000000000002",
"created_at": Any<Date>,
"id": Any<String>,
"organization_id": "10000000-0000-0000-0000-000000000102",
"real_student_number": "12345",
"registration_date": null,
"updated_at": Any<Date>,
"user_id": "20000000-0000-0000-0000-000000000102",
},
Object {
"completion_id": "30000000-0000-0000-0000-000000000103",
"course_id": "00000000-0000-0000-0000-000000000001",
"created_at": Any<Date>,
"id": Any<String>,
"organization_id": "10000000-0000-0000-0000-000000000102",
"real_student_number": "12345",
"registration_date": null,
"updated_at": Any<Date>,
"user_id": "20000000-0000-0000-0000-000000000102",
},
]
{
"addedCompletions": [
{
"completion_id": "30000000-0000-0000-0000-000000000102",
"course_id": "00000000-0000-0000-0000-000000000002",
"created_at": Any<Date>,
"id": StringMatching /\\[a-f\\\\d\\]\\{8\\}-\\[a-f\\\\d\\]\\{4\\}-\\[a-f\\\\d\\]\\{4\\}-\\[a-f\\\\d\\]\\{4\\}-\\[a-f\\\\d\\]\\{12\\}/i,
"organization_id": "10000000-0000-0000-0000-000000000102",
"real_student_number": "12345",
"registration_date": null,
"updated_at": Any<Date>,
"user_id": "20000000-0000-0000-0000-000000000102",
},
{
"completion_id": "30000000-0000-0000-0000-000000000103",
"course_id": "00000000-0000-0000-0000-000000000001",
"created_at": Any<Date>,
"id": StringMatching /\\[a-f\\\\d\\]\\{8\\}-\\[a-f\\\\d\\]\\{4\\}-\\[a-f\\\\d\\]\\{4\\}-\\[a-f\\\\d\\]\\{4\\}-\\[a-f\\\\d\\]\\{12\\}/i,
"organization_id": "10000000-0000-0000-0000-000000000102",
"real_student_number": "12345",
"registration_date": null,
"updated_at": Any<Date>,
"user_id": "20000000-0000-0000-0000-000000000102",
},
],
}
`;
53 changes: 26 additions & 27 deletions backend/api/routes/__test__/__snapshots__/progress.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`API /api/progressv2 returns correct data on course id, include deleted false 1`] = `
Object {
"data": Object {
"completion": Object {
{
"data": {
"completion": {
"certificate_id": null,
"completion_date": "2000-01-01T08:00:00.000Z",
"completion_language": null,
Expand All @@ -21,8 +21,8 @@ Object {
"user_upstream_id": 1,
},
"course_id": "00000000-0000-0000-0000-000000000001",
"exercise_completions": Object {
"50000000-0000-0000-0000-000000000001": Object {
"exercise_completions": {
"50000000-0000-0000-0000-000000000001": {
"completed": true,
"exercise_id": "50000000-0000-0000-0000-000000000001",
"max_points": 2,
Expand All @@ -32,7 +32,7 @@ Object {
"section": 1,
"user_id": "20000000-0000-0000-0000-000000000102",
},
"50000000-0000-0000-0000-000000000002": Object {
"50000000-0000-0000-0000-000000000002": {
"completed": false,
"exercise_id": "50000000-0000-0000-0000-000000000002",
"max_points": 3,
Expand All @@ -49,9 +49,9 @@ Object {
`;

exports[`API /api/progressv2 returns correct data on course id, include deleted true 1`] = `
Object {
"data": Object {
"completion": Object {
{
"data": {
"completion": {
"certificate_id": null,
"completion_date": "2000-01-01T08:00:00.000Z",
"completion_language": null,
Expand All @@ -69,8 +69,8 @@ Object {
"user_upstream_id": 1,
},
"course_id": "00000000-0000-0000-0000-000000000001",
"exercise_completions": Object {
"50000000-0000-0000-0000-000000000001": Object {
"exercise_completions": {
"50000000-0000-0000-0000-000000000001": {
"completed": true,
"exercise_id": "50000000-0000-0000-0000-000000000001",
"max_points": 2,
Expand All @@ -80,7 +80,7 @@ Object {
"section": 1,
"user_id": "20000000-0000-0000-0000-000000000102",
},
"50000000-0000-0000-0000-000000000002": Object {
"50000000-0000-0000-0000-000000000002": {
"completed": false,
"exercise_id": "50000000-0000-0000-0000-000000000002",
"max_points": 3,
Expand All @@ -90,7 +90,7 @@ Object {
"section": 2,
"user_id": "20000000-0000-0000-0000-000000000102",
},
"50000000-0000-0000-0000-000000000005": Object {
"50000000-0000-0000-0000-000000000005": {
"completed": false,
"exercise_id": "50000000-0000-0000-0000-000000000005",
"max_points": null,
Expand All @@ -107,9 +107,9 @@ Object {
`;

exports[`API /api/progressv2 returns correct data on course slug, include deleted false 1`] = `
Object {
"data": Object {
"completion": Object {
{
"data": {
"completion": {
"certificate_id": null,
"completion_date": "2000-01-01T08:00:00.000Z",
"completion_language": null,
Expand All @@ -127,8 +127,8 @@ Object {
"user_upstream_id": 1,
},
"course_id": "00000000-0000-0000-0000-000000000001",
"exercise_completions": Object {
"50000000-0000-0000-0000-000000000001": Object {
"exercise_completions": {
"50000000-0000-0000-0000-000000000001": {
"completed": true,
"exercise_id": "50000000-0000-0000-0000-000000000001",
"max_points": 2,
Expand All @@ -138,7 +138,7 @@ Object {
"section": 1,
"user_id": "20000000-0000-0000-0000-000000000102",
},
"50000000-0000-0000-0000-000000000002": Object {
"50000000-0000-0000-0000-000000000002": {
"completed": false,
"exercise_id": "50000000-0000-0000-0000-000000000002",
"max_points": 3,
Expand All @@ -155,9 +155,9 @@ Object {
`;

exports[`API /api/progressv2 returns correct data on course slug, include deleted true 1`] = `
Object {
"data": Object {
"completion": Object {
{
"data": {
"completion": {
"certificate_id": null,
"completion_date": "2000-01-01T08:00:00.000Z",
"completion_language": null,
Expand All @@ -175,8 +175,8 @@ Object {
"user_upstream_id": 1,
},
"course_id": "00000000-0000-0000-0000-000000000001",
"exercise_completions": Object {
"50000000-0000-0000-0000-000000000001": Object {
"exercise_completions": {
"50000000-0000-0000-0000-000000000001": {
"completed": true,
"exercise_id": "50000000-0000-0000-0000-000000000001",
"max_points": 2,
Expand All @@ -186,7 +186,7 @@ Object {
"section": 1,
"user_id": "20000000-0000-0000-0000-000000000102",
},
"50000000-0000-0000-0000-000000000002": Object {
"50000000-0000-0000-0000-000000000002": {
"completed": false,
"exercise_id": "50000000-0000-0000-0000-000000000002",
"max_points": 3,
Expand All @@ -196,7 +196,7 @@ Object {
"section": 2,
"user_id": "20000000-0000-0000-0000-000000000102",
},
"50000000-0000-0000-0000-000000000005": Object {
"50000000-0000-0000-0000-000000000005": {
"completed": false,
"exercise_id": "50000000-0000-0000-0000-000000000005",
"max_points": null,
Expand All @@ -211,4 +211,3 @@ Object {
},
}
`;

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`API /api/temporary-stored-data get returns stored data from owned course 1`] = `
Array [
Object {
"completions": Array [
Object {
[
{
"completions": [
{
"certificate_id": null,
"completion_date": "2000-01-01T08:00:00.000Z",
"completion_language": null,
Expand All @@ -22,14 +22,14 @@ Array [
"user_upstream_id": 1,
},
],
"storedData": Object {
"storedData": {
"course_id": "00000000-0000-0000-0000-000000000001",
"created_at": "1900-01-01T08:00:00.000Z",
"data": "user1_foo",
"updated_at": "1900-01-01T08:00:00.000Z",
"user_id": "20000000-0000-0000-0000-000000000102",
},
"user": Object {
"user": {
"administrator": false,
"created_at": "1900-01-01T08:00:00.000Z",
"email": "[email protected]",
Expand Down
29 changes: 17 additions & 12 deletions backend/api/routes/__test__/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createRequestHelpers,
fakeTMCCurrent,
getTestContext,
ID_REGEX,
RequestGet,
RequestPost,
} from "../../../tests"
Expand Down Expand Up @@ -229,18 +230,22 @@ describe("API", () => {
},
})

expect(orderBy(addedCompletions, "completion_id")).toMatchSnapshot([
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
])
expect({
addedCompletions: orderBy(addedCompletions, "completion_id"),
}).toMatchSnapshot({
addedCompletions: [
{
id: expect.stringMatching(ID_REGEX),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
{
id: expect.stringMatching(ID_REGEX),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
})
})
})
})
2 changes: 2 additions & 0 deletions backend/bin/kafkaBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ app.use(compression())
app.use(express.json())
app.use(morgan("combined"))

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const port = parseInt(KAFKA_BRIDGE_SERVER_PORT || "3003")
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const host = KAFKA_BRIDGE_SERVER_HOST || "0.0.0.0"

app.post("/kafka-bridge/api/v0/event", async (req, res) => {
Expand Down
Loading

0 comments on commit 0eaff72

Please sign in to comment.