Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/typed current page #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions validation-tool-backend/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:16.15.0-alpine3.14

RUN apk --no-cache add git

RUN git clone https://github.com/Coleridge-Initiative/validation-tool/

WORKDIR validation-tool/validation-tool-backend

COPY .env .env

RUN npm install

RUN npm run build

EXPOSE 3000

CMD ["node", "dist/main.js"]
2,798 changes: 1,432 additions & 1,366 deletions validation-tool-backend/package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions validation-tool-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
"@nestjs/common": "^8.0.0",
"@nestjs/config": "^1.1.6",
"@nestjs/core": "^8.0.0",
"@nestjs/jwt": "^8.0.0",
"@nestjs/jwt": "^10.0.1",
"@nestjs/passport": "^8.0.1",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/platform-express": "^9.2.1",
"bcrypt": "^5.0.1",
"mssql": "^7.3.0",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"mssql": "^9.1.1",
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^8.0.0",
"@nestjs/cli": "^9.1.9",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
"@types/bcrypt": "^5.0.0",
Expand All @@ -56,7 +56,7 @@
"jest": "^27.2.5",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"supertest": "^6.3.3",
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
Expand Down
26 changes: 18 additions & 8 deletions validation-tool-backend/src/review/review.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,35 @@ export class ReviewController {
page_number = 0;
}
const user: User = req.user;
if (do_show_reviewed_items == '1') {
do_show_reviewed_items = true;
} else {
do_show_reviewed_items = false;
}
return await this.reviewService.getReviewItems(
user.id,
page_size,
page_number,
do_show_reviewed_items
do_show_reviewed_items,
);
}

@Get('/count')
@UseGuards(JwtAuthGuard)
async getReviewItensCount(
@Req() req,
@Query('do_show_reviewed_items') do_show_reviewed_items
) {
@Query('do_show_reviewed_items') do_show_reviewed_items,
) {
const user: User = req.user;
const result = await this.reviewService.getReviewItensCount(user.id, do_show_reviewed_items);
if (do_show_reviewed_items == '1') {
do_show_reviewed_items = true;
} else {
do_show_reviewed_items = false;
}
const result = await this.reviewService.getReviewItensCount(
user.id,
do_show_reviewed_items,
);
return result;
}

Expand All @@ -67,10 +80,7 @@ export class ReviewController {
@Body() body: ValidationGenericMetadataDto,
) {
const user: User = req.user;
await this.reviewService.reviewDatasetMentionParentAlias(
user.id,
body,
);
await this.reviewService.reviewDatasetMentionParentAlias(user.id, body);
return true;
}
}
27 changes: 14 additions & 13 deletions validation-tool-backend/src/review/review.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common';
import { BigInt, Int, VarChar } from 'mssql';
import { BigInt, Int, Bit, VarChar } from 'mssql';
import { DatabaseService } from 'src/database/database.service';
import {
ReviewItem,
Expand All @@ -25,7 +25,7 @@ export class ReviewService {
.input('EntityID', BigInt, source_id) // EntityID or source_id is the ID of the user.
.input('Fetch', BigInt, page_size)
.input('Offset', BigInt, page_number * page_size)
.input('DoShowWReviewedItems', Int, do_show_reviewed_items).query(`SELECT
.input('DoShowWReviewedItems', Bit, do_show_reviewed_items).query(`SELECT
su.id as user_metadata_source_id,
sv.id as dataset_mention_generic_metadata_id,
dy.snippet as dataset_mention,
Expand Down Expand Up @@ -65,11 +65,13 @@ export class ReviewService {

async getReviewItensCount(
source_id: number,
do_show_reviewed_items = 1
do_show_reviewed_items = 1,
): Promise<{ total: number; answered: number }> {
const pool = await this.databaseService.getConnection();
const result = await pool.request().input('EntityID', BigInt, source_id).input('DoShowWReviewedItems', Int, do_show_reviewed_items)
.query(`SELECT
const result = await pool
.request()
.input('EntityID', BigInt, source_id)
.input('DoShowWReviewedItems', Bit, do_show_reviewed_items).query(`SELECT
COUNT(*) as items_number,
SUM (CASE WHEN sv.agency_dataset_identified is not null and sv.is_dataset_reference is not null THEN 1 ELSE 0 END) as answered,
su.id as entity_id
Expand Down Expand Up @@ -99,7 +101,6 @@ export class ReviewService {
return count_result;
}


async updateDatasetAliasCandidateReview(
user_id: number,
validation: ValidationGenericMetadataDto,
Expand All @@ -121,7 +122,6 @@ export class ReviewService {
return this.updateDatasetAliasCandidateReview(user_id, validation);
}


async updateParentAliasReview(
source_id: number,
validation: ValidationGenericMetadataDto,
Expand All @@ -136,12 +136,11 @@ export class ReviewService {
return result.rowsAffected;
}


async reviewDatasetMentionParentAlias(
source_id: number,
validation: ValidationGenericMetadataDto,
) {
return this.updateParentAliasReview(source_id, validation);
return this.updateParentAliasReview(source_id, validation);
}

async getValidation(
Expand Down Expand Up @@ -211,7 +210,11 @@ sum(case when gm.generic_metadata_id is not null then 1 else 0 end) as assigned_
return items;
}

async assignitems(source_id: number, organization_source_id: number, organization_name: string) {
async assignitems(
source_id: number,
organization_source_id: number,
organization_name: string,
) {
const pool = await this.databaseService.getConnection();
const result = await pool
.request()
Expand Down Expand Up @@ -258,9 +261,7 @@ sum(case when gm.generic_metadata_id is not null then 1 else 0 end) as assigned_
async checkAndAssignNewItems() {
const report = await this.getReviewReport();
for (const reportItem of report) {
if (
reportItem.not_answered === 0
) {
if (reportItem.not_answered === 0) {
await this.deleteAssignments(reportItem.user_metadata_source_id);
await this.assignitems(
reportItem.user_metadata_source_id,
Expand Down
31 changes: 31 additions & 0 deletions validation-tool-frontend/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM nginx:1.15-alpine

RUN apk upgrade

RUN apk add --no-cache --repository http://nl.alpinelinux.org/alpine/edge/main libuv

RUN apk add --no-cache --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main nodejs=16.15.0-r1 npm=8.10.0-r0

RUN apk add --no-cache --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community yarn=1.22.19-r0

RUN apk --no-cache add git

RUN git clone https://github.com/Coleridge-Initiative/validation-tool/

WORKDIR validation-tool/validation-tool-frontend

COPY .env.production .env.production

COPY vue.config.js vue.config.js

RUN yarn install

RUN npm run build

ENV CONTEXT_PATH_NAME validation

COPY nginx.conf /etc/nginx/conf.d/custom.template

EXPOSE 80

CMD (envsubst '\$CONTEXT_PATH_NAME' < /etc/nginx/conf.d/custom.template > /etc/nginx/conf.d/default.conf) && nginx -g 'daemon off;'
19 changes: 19 additions & 0 deletions validation-tool-frontend/docker/nginx.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
server {
listen 80;
server_name localhost;

root /validation-tool/validation-tool-frontend/dist;
index index.html;

location = /${CONTEXT_PATH_NAME} {
rewrite ^/${CONTEXT_PATH_NAME}$ /${CONTEXT_PATH_NAME}/ permanent;
}

location /${CONTEXT_PATH_NAME} {
rewrite ^/${CONTEXT_PATH_NAME}(.*)$ /$1 last;
}

location / {
try_files $uri /index.html;
}
}
Loading