Skip to content

Commit

Permalink
Merge pull request #43 from Sunbird-ALL/all-1.3-staging
Browse files Browse the repository at this point in the history
Merge changes from staging to dev
  • Loading branch information
sudeeppr1998 authored Oct 16, 2024
2 parents 096f7bd + c011c82 commit a9235ef
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 276 deletions.
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
254 changes: 2 additions & 252 deletions src/controllers/content.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ export class contentController {
queryData.contentType,
queryData.mechanics_id,
parseInt(Batch),
queryData.language
queryData.language,
queryData.level_competency
);
}

Expand Down Expand Up @@ -1244,255 +1245,4 @@ export class contentController {
deleted,
});
}

@ApiExcludeEndpoint(true)
@ApiBody({
description: 'Request body parameters for get content',
required: true,
schema: {
type: 'object',
properties: {
tokenArr: {
type: 'array',
description: 'Array of tokens',
items: {
type: 'string',
example: 'c'
}
},
language: {
type: 'string',
description: 'Language code',
example: 'en'
},
contentType: {
type: 'string',
description: 'Type of content',
example: 'Word'
},
limit: {
type: 'number',
description: 'Limit on the number of items',
example: 5
},
cLevel: {
type: 'string',
description: 'Content level',
example: 'L2'
},
complexityLevel: {
type: 'array',
description: 'Array of complexity levels',
items: {
type: 'string',
example: 'C1'
}
},
graphemesMappedObj: {
type: 'object',
description: 'Object mapping graphemes to their representations',
additionalProperties: {
type: 'array',
items: {
type: 'string',
example: 'ch'
}
},
example: {
"c": ["ch"],
"o": ["o"],
"a": ["a"],
"v": ["v", "ve"],
"w": ["w", "wh"],
"æ": ["a", "ai", "au"],
"n": ["n"],
"i": ["i"],
"θ": ["th"]
}
}
}
}
})
@ApiResponse({
status: 200,
description: 'Successful response',
schema: {
type: 'object',
properties: {
status: { type: 'string', example: 'success' },
data: {
type: 'object',
properties: {
wordsArr: {
type: 'array',
items: {
type: 'object',
properties: {
_id: { type: 'string', example: '660f9545367a62b3902dd58b' },
contentId: { type: 'string', example: 'f8dd7c97-53f7-4676-b597-4a52aaface5c' },
collectionId: { type: 'string', example: '6a519951-8635-4d89-821a-d3eb60f6e1ec' },
name: { type: 'string', example: 'L2_new_3' },
contentType: { type: 'string', example: 'Word' },
contentSourceData: {
type: 'array',
items: {
type: 'object',
properties: {
language: { type: 'string', example: 'en' },
audioUrl: { type: 'string', example: '' },
text: { type: 'string', example: 'five' },
phonemes: {
type: 'array',
items: { type: 'string', example: 'f' }
},
wordCount: { type: 'number', example: 1 },
wordFrequency: {
type: 'object',
additionalProperties: { type: 'number', example: 1 }
},
syllableCount: { type: 'number', example: 4 },
syllableCountMap: {
type: 'object',
additionalProperties: { type: 'number', example: 4 }
},
syllableCountArray: {
type: 'array',
items: {
type: 'object',
properties: {
k: { type: 'string', example: 'five' },
v: { type: 'number', example: 4 }
}
}
}
}
}
},
status: { type: 'string', example: 'live' },
publisher: { type: 'string', example: 'ekstep' },
language: { type: 'string', example: 'en' },
contentIndex: { type: 'number', example: 141 },
tags: {
type: 'array',
items: { type: 'string' }
},
createdAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' },
updatedAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' },
__v: { type: 'number', example: 0 },
matchedChar: {
type: 'array',
items: { type: 'string', example: 'v' }
}
}
}
},
contentForToken: {
type: 'object',
additionalProperties: {
type: 'array',
items: {
type: 'object',
properties: {
_id: { type: 'string', example: '660f9545367a62b3902dd58b' },
contentId: { type: 'string', example: 'f8dd7c97-53f7-4676-b597-4a52aaface5c' },
collectionId: { type: 'string', example: '6a519951-8635-4d89-821a-d3eb60f6e1ec' },
name: { type: 'string', example: 'L2_new_3' },
contentType: { type: 'string', example: 'Word' },
contentSourceData: {
type: 'array',
items: {
type: 'object',
properties: {
language: { type: 'string', example: 'en' },
audioUrl: { type: 'string', example: '' },
text: { type: 'string', example: 'five' },
phonemes: {
type: 'array',
items: { type: 'string', example: 'f' }
},
wordCount: { type: 'number', example: 1 },
wordFrequency: {
type: 'object',
additionalProperties: { type: 'number', example: 1 }
},
syllableCount: { type: 'number', example: 4 },
syllableCountMap: {
type: 'object',
additionalProperties: { type: 'number', example: 4 }
},
syllableCountArray: {
type: 'array',
items: {
type: 'object',
properties: {
k: { type: 'string', example: 'five' },
v: { type: 'number', example: 4 }
}
}
}
}
}
},
status: { type: 'string', example: 'live' },
publisher: { type: 'string', example: 'ekstep' },
language: { type: 'string', example: 'en' },
contentIndex: { type: 'number', example: 141 },
tags: {
type: 'array',
items: { type: 'string' }
},
createdAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' },
updatedAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' },
__v: { type: 'number', example: 0 },
matchedChar: {
type: 'array',
items: { type: 'string', example: 'v' }
}
}
}
}
}
}
}
}
}
})
@ApiResponse({
status: 500,
description: 'Error while fetching data from the content table',
schema: {
type: 'object',
properties: {
status: { type: 'string', example: 'error' },
msg: { type: 'string', example: 'Server error - error message' },
},
},
})
@ApiOperation({
summary: 'Get all data from the content table'
})
@Get('/getMeachnicsContent')
async getMechanicsContent(
@Res() response: FastifyReply,
@Query('contentType') contentType: string,@Query('mechanics_id') mechanics_id: string, @Query() { contentlimit = 5 }, @Query('language') language: string
) {
try {
const Batch: any = contentlimit || 5;
const contentCollection = await this.contentService.getMechanicsContentData(
contentType,
mechanics_id,
Batch,
language
);
return response.status(HttpStatus.CREATED).send({
status: 200,
contentCollection,
});
} catch (error) {
return response.status(HttpStatus.INTERNAL_SERVER_ERROR).send({
status: 500,
message: 'Server error - ' + error,
});
}
}
}
Loading

0 comments on commit a9235ef

Please sign in to comment.