Skip to content

Commit

Permalink
Merge pull request #51 from Sunbird-ALL/all-1.3-dev
Browse files Browse the repository at this point in the history
Merging changes to main from all 1.3 dev for release
  • Loading branch information
sudeeppr1998 authored Oct 24, 2024
2 parents c7b49d6 + 25ca1c3 commit eb4b27b
Show file tree
Hide file tree
Showing 5 changed files with 537 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: DEV DEPLOYMENT

on:
push:
branches: [ all-1.1-dev ]
branches: [ all-1.3-dev ]

jobs:
build:
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: STAGING DEPLOYMENT

on:
push:
branches: [ all-1.3-staging ]

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME_DEVOPS }}
password: ${{ secrets.DOCKERHUB_TOKEN_DEVOPS }}

-
name: Load .env from GitHub Secret
run: echo "${{ secrets.MY_ENV_VARS_STAGING }}" > .env

-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_STAGING }}:${{ secrets.IMAGE_TAG }}
env:
MY_ENV_VARS: ${{ secrets.MY_ENV_VARS_STAGING }}
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Deploy Stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
ssh -i ~/.ssh/all_staging_key.pem ${{ secrets.USERNAME_STAGING }}@${{ secrets.HOST_STAGING }} 'bash -s' << 'EOF'
docker login
docker container stop ${{ secrets.CONTAINER_NAME }}
docker rm ${{ secrets.CONTAINER_NAME }}
docker rmi ${{ secrets.CONTAINER_REGISTRY_STAGING }}:${{ secrets.IMAGE_TAG }}
docker pull ${{ secrets.CONTAINER_REGISTRY_STAGING }}:${{ secrets.IMAGE_TAG }}
cd /home/all-staging-user/all-services/all-content-service
sudo docker-compose up -d --force-recreate --no-deps
EOF
36 changes: 26 additions & 10 deletions src/controllers/content.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,16 +888,32 @@ export class contentController {
async getContent(@Res() response: FastifyReply, @Body() queryData: any) {
try {
const Batch: any = queryData.limit || 5;
const contentCollection = await this.contentService.search(
queryData.tokenArr,
queryData.language,
queryData.contentType,
parseInt(Batch),
queryData.tags,
queryData.cLevel,
queryData.complexityLevel,
queryData.graphemesMappedObj,
);

let contentCollection;

if(queryData.mechanics_id === undefined){
contentCollection = await this.contentService.search(
queryData.tokenArr,
queryData.language,
queryData.contentType,
parseInt(Batch),
queryData.tags,
queryData.cLevel,
queryData.complexityLevel,
queryData.graphemesMappedObj,
queryData.level_competency
);
}else{
contentCollection = await this.contentService.getMechanicsContentData(
queryData.contentType,
queryData.mechanics_id,
parseInt(Batch),
queryData.language,
queryData.level_competency,
queryData.tags
);
}

return response.status(HttpStatus.CREATED).send({
status: 'success',
data: contentCollection,
Expand Down
42 changes: 41 additions & 1 deletion src/schemas/content.schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, now, Mixed } from 'mongoose';
import { v4 as uuidv4 } from 'uuid';
import { IsNumber, IsOptional, IsString } from 'class-validator';
import { IsOptional, IsString, IsNumber, IsArray, IsObject } from 'class-validator';

@Schema({ collection: 'content' })
export class content {
Expand Down Expand Up @@ -30,6 +30,46 @@ export class content {
@Prop({ required: true })
contentSourceData: [Mixed];

@Prop({ required: false, type: Array })
@IsOptional()
@IsArray()
mechanics_data: [
{
mechanics_id: string;
language:string;
jumbled_text: string;
text: string;
audio_url: string;
image_url: string;
options: [
{
text: string;
audio_url: string;
image_url: string;
isAns: boolean;
side: string;
}
];
hints: {
text: string;
audio_url: string;
image_url: string;
};
time_limit: number;
correctness: {
"50%": [string],
}
}
];

@Prop({ type: Object, required: false })
@IsOptional()
@IsObject()
level_complexity: {
level: string;
level_competency: string;
};

@Prop({ type: String, required: false })
@IsOptional()
@IsString()
Expand Down
Loading

0 comments on commit eb4b27b

Please sign in to comment.