Skip to content

Commit

Permalink
Merge pull request #441 from intersective/prerelease
Browse files Browse the repository at this point in the history
Prerelease
  • Loading branch information
rodentskie authored Jun 15, 2024
2 parents 8cb7748 + acb67f6 commit 83a79af
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/p2-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
################################################
# GITHUB REPO CHECKOUT
################################################
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{ env.BRANCH_TAG_NAME }}
Expand All @@ -80,9 +80,9 @@ jobs:
# NODE ENV
################################################
- name: Setup Node.js environment
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '14'
node-version: '18'


################################################
Expand Down
57 changes: 40 additions & 17 deletions .github/workflows/p2-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ name: Deploy to p2-sandbox environment
################################################
on:
workflow_dispatch:
inputs:
INPUT_BRANCH:
description: 'Branch or tag to deploy'
required: true
default: ''
push:
branches: [ 'develop' ]
branches:
- 'pvt'


################################################
Expand All @@ -31,7 +37,7 @@ jobs:
env:
REGION : ap-southeast-2
ENV : dev # Valid values are dev,test,live only
STACK_NAME: p2-sandbox # Valid values are au,us,uk,p2,lf,nu,p1-sandbox,p1-stage,p2-sandbox,shared only
STACK_NAME: p2-sandbox # Valid values are au,us,uk,p2,lf,nu,p1-sandbox,p2-sandbox,p2-sandbox,shared only
ROOTSTACK: cutie-app
CFNS3BucketName: devops-cfn-templates
PRIVATES3BucketName: devops-shared-private
Expand All @@ -42,28 +48,41 @@ jobs:
REQUESTOR: ${{ github.event.inputs.REQUESTOR }}
REASON: ${{ github.event.inputs.REASON }}
ENDPOINT: cutie-app.p2-sandbox.practera.com
BRANCH_TAG_NAME: develop
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}




steps:

################################################
# Export BRANCH_TAG_NAME
################################################
- name: Get branch for env BRANCH_TAG_NAME
run: |
if [ -z "$INPUT_BRANCH" ]; then
echo "BRANCH_TAG_NAME="$(echo "$GITHUB_REF_NAME") >> $GITHUB_ENV
else
echo "BRANCH_TAG_NAME="$(echo "$INPUT_BRANCH") >> $GITHUB_ENV
fi
env:
INPUT_BRANCH: ${{ github.event.inputs.INPUT_BRANCH }}

################################################
# GITHUB REPO CHECKOUT
################################################
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis


ref: ${{ env.BRANCH_TAG_NAME }}

################################################
# NODE ENV
################################################
- name: Setup Node.js environment
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '14'
node-version: '18'


################################################
Expand Down Expand Up @@ -94,7 +113,6 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm install


################################################
# SEGMENT ENV VARIABLE SUBSTITUION - INDEX.HTML
################################################
Expand All @@ -109,7 +127,7 @@ jobs:
cat ./src/index.html
env:
SEGMENT_KEY: AsLmvmyUc9LdCxFn0xqQhVz9CL2KCFc1

################################################
# GET P2 SANDBOX AWS ORGANIZATION NUMBER
################################################
Expand All @@ -128,7 +146,8 @@ jobs:
with:
role-to-assume: arn:aws:iam::${{ steps.AWS_ORG.outputs.P2SANDBOX }}:role/github-restricted-role-to-assume
region: ${{ env.REGION }}



##########################################################
# AWS S3 SYNC - SERVERLESS TEMPLATES
##########################################################
Expand All @@ -146,7 +165,10 @@ jobs:
cat >> .env <<EOF
CDNSharedACMCertificateArn=$(aws cloudformation list-exports --query "Exports[?Name==\`$STACK_NAME-CDNSharedACMCertificateArn-$ENV\`].Value" --no-paginate --output text)
ChatBotSNSTopicARN=$(aws cloudformation list-exports --query "Exports[?Name==\`$STACK_NAME-ChatBotSNSTopicARN-$ENV\`].Value" --no-paginate --output text)
COMMIT_ID=$(git rev-parse --short "$GITHUB_SHA")
BRANCH_TAG_ID=${GITHUB_REF#refs/heads/}
VantaOwner=sunil@practera.com
VantaDescription=${{ env.STACK_NAME }}-${{ env.ROOTSTACK }}
EOF
Expand All @@ -173,9 +195,9 @@ jobs:
run: |
printf "Creating required secret variables for angular environment variable creation\n\n"
export CUSTOM_APPKEY=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-AppKeySecret-$ENV| jq --raw-output '.SecretString' | jq -r .appkey)
export CUSTOM_FILESTACK_SIGNATURE=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-FilestackSecret-$ENV| jq --raw-output '.SecretString' | jq -r .signature)
export CUSTOM_FILESTACK_VIRUS_DETECTION=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-FilestackSecret-$ENV| jq --raw-output '.SecretString' | jq -r .virusdetection)
export CUSTOM_APPKEY=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-AppKeySecret-$ENV| jq --raw-output '.SecretString' | jq -r .appkey)
export CUSTOM_FILESTACK_SIGNATURE=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-FilestackSecret-$ENV| jq --raw-output '.SecretString' | jq -r .signature)
export CUSTOM_FILESTACK_VIRUS_DETECTION=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-FilestackSecret-$ENV| jq --raw-output '.SecretString' | jq -r .virusdetection)
export CUSTOM_FILESTACK_KEY=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-FilestackSecret-$ENV| jq --raw-output '.SecretString' | jq -r .apikey)
export CUSTOM_FILESTACK_POLICY=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-FilestackSecret-$ENV| jq --raw-output '.SecretString' | jq -r .policy)
export CUSTOM_PUSHER_APPID=$(aws secretsmanager get-secret-value --secret-id $STACK_NAME-PusherSecret-$ENV| jq --raw-output '.SecretString' | jq -r .app_id)
Expand Down Expand Up @@ -206,6 +228,7 @@ jobs:
CUSTOM_ONBOARDING_FORM_IN_RAW_HTML: 0
CUSTOM_ONBOARDING_POPUP_FORM_ID: 67a53834-ffac-4ebc-81cd-39f9e77167d8


###############################################################
# BUILD WEB PACKAGES
##############################################################
Expand Down Expand Up @@ -289,4 +312,4 @@ jobs:
pip install --upgrade csvtotable
aws s3 cp s3://$STATUSREPORTS3Bucket/deploy-reporting.sh deploy-reporting.sh
chmod +x deploy-reporting.sh && ./deploy-reporting.sh
echo "LINK="${GITHUB_REPOSITORY##*/}.html >> $GITHUB_ENV
echo "LINK="${GITHUB_REPOSITORY##*/}.html >> $GITHUB_ENV
32 changes: 26 additions & 6 deletions .github/workflows/p2-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ name: Deploy to p2-stage environment
################################################
on:
workflow_dispatch:
inputs:
INPUT_BRANCH:
description: 'Branch or tag to deploy'
required: true
default: ''
push:
branches: [ 'trunk' ]
branches:
- 'trunk'

################################################
# GITHUB ACTION JOBS
Expand Down Expand Up @@ -41,16 +47,30 @@ jobs:
REQUESTOR: ${{ github.event.inputs.REQUESTOR }}
REASON: ${{ github.event.inputs.REASON }}
ENDPOINT: cutie-app.p2-stage.practera.com
BRANCH_TAG_NAME: trunk
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}

steps:

################################################
# GITHUB REPO CHECKOUT
# Export BRANCH_TAG_NAME
################################################
steps:
- uses: actions/checkout@v2
- name: Get branch for env BRANCH_TAG_NAME
run: |
if [ -z "$INPUT_BRANCH" ]; then
echo "BRANCH_TAG_NAME="$(echo "$GITHUB_REF_NAME") >> $GITHUB_ENV
else
echo "BRANCH_TAG_NAME="$(echo "$INPUT_BRANCH") >> $GITHUB_ENV
fi
env:
INPUT_BRANCH: ${{ github.event.inputs.INPUT_BRANCH }}

################################################
# GITHUB REPO CHECKOUT
################################################
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{ env.BRANCH_TAG_NAME }}



Expand All @@ -60,7 +80,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '18'


################################################
Expand Down
88 changes: 81 additions & 7 deletions src/app/overview/overview.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, Input } from '@angular/core';
import { Experience, Statistics, Tag, OverviewService } from './overview.service';
import { Experience, Statistics, UserCount, Tag, OverviewService } from './overview.service';
import { UtilsService } from '@services/utils.service';
import { PopupService } from '@shared/popup/popup.service';
import { StorageService } from '@services/storage.service';
Expand Down Expand Up @@ -113,6 +113,7 @@ export class OverviewComponent implements OnInit {
this.service.getExperiences().subscribe(res => {
// reformat tags from string[] to Tag[]
this.experiencesRaw = res;
this._fixStatistics();
// remove experiences didn't have admin or coordinator role
this._filterByRole();
// get all tags
Expand All @@ -122,6 +123,7 @@ export class OverviewComponent implements OnInit {
this.filterAndOrder();
this.loadingExps = false;
});

}


Expand Down Expand Up @@ -240,6 +242,76 @@ export class OverviewComponent implements OnInit {
this._renderExperiences();
}

// ensure that statistics object is always available
// and that all fields are initialized to 0
// "statistics": {
// "enrolledUserCount": {
// "admin": 0,
// "coordinator": 0,
// "mentor": 0,
// "participant": 0,
// "__typename": "UserCount"
// },
// "registeredUserCount": {
// "admin": 0,
// "coordinator": 0,
// "mentor": 0,
// "participant": 0,
// "__typename": "UserCount"
// },
// "activeUserCount": {
// "admin": 0,
// "coordinator": 0,
// "mentor": 0,
// "participant": 0,
// "__typename": "UserCount"
// },
// "feedbackLoopStarted": 0,
// "feedbackLoopCompleted": 0,
// "reviewRatingAvg": 0,
// "onTrackRatio": 0,
// "__typename": "ExpStatistics"
// }
private _fixStatistics() {
this.experiencesRaw = this.experiencesRaw.map(exp => this._doStatisticsFix(exp));
}

private _doStatisticsFix(exp: Experience) {
{
//console.log('fixing statistics', exp.statistics);
if (!exp.statistics) {
exp.statistics = {} as Statistics;
}
exp.statistics.enrolledUserCount = exp.statistics.enrolledUserCount || {
admin: 0,
coordinator: 0,
mentor: 0,
participant: 0
} as UserCount;

exp.statistics.registeredUserCount = exp.statistics.registeredUserCount || {
admin: 0,
coordinator: 0,
mentor: 0,
participant: 0
} as UserCount;

exp.statistics.activeUserCount = exp.statistics.activeUserCount || {
admin: 0,
coordinator: 0,
mentor: 0,
participant: 0
} as UserCount;

exp.statistics.feedbackLoopStarted = exp.statistics.feedbackLoopStarted || 0;
exp.statistics.feedbackLoopCompleted = exp.statistics.feedbackLoopCompleted || 0;
exp.statistics.reviewRatingAvg = exp.statistics.reviewRatingAvg || 0;
exp.statistics.onTrackRatio = exp.statistics.onTrackRatio || 0;

//console.log('fixed statistics', exp.statistics);
return exp; // Return the modified experience
}
}
private _filterByTag() {
const activeTags = this.tags.filter(t => t.active).map(t => t.name);
if (!activeTags.length) {
Expand Down Expand Up @@ -353,20 +425,21 @@ export class OverviewComponent implements OnInit {
let fbCompleted = 0;
let fbStarted = 0;
let reviewRatingAvg = 0;
let reviewRatingCount = 0;
this.experiences.forEach(exp => {
if (exp.status === 'live') {
liveExpCount ++;
liveExpCount++;
}
const stat = exp.statistics;
activeUsers += stat.activeUserCount.participant + stat.activeUserCount.mentor;
totalUsers += stat.registeredUserCount.participant + stat.registeredUserCount.mentor;
fbCompleted += stat.feedbackLoopCompleted;
fbStarted += stat.feedbackLoopStarted;
if (reviewRatingAvg === 0) {
reviewRatingAvg = stat.reviewRatingAvg;
} else if (stat.reviewRatingAvg > 0) {
// if stat.reviewRatingAvg <= 0, don't count it for the average
reviewRatingAvg = (reviewRatingAvg + stat.reviewRatingAvg) / 2;

// Assuming there's a count variable initialized to 0 outside this snippet
if (stat.reviewRatingAvg > 0) {
reviewRatingAvg = ((reviewRatingAvg * reviewRatingCount) + stat.reviewRatingAvg) / (reviewRatingCount + 1);
reviewRatingCount += 1; // Increment count only if a valid reviewRatingAvg is added
}
});
this.stats[0].value = liveExpCount.toString();
Expand All @@ -382,6 +455,7 @@ export class OverviewComponent implements OnInit {
return;
}
res.forEach(exp => {
exp = this._doStatisticsFix(exp);
// update both experiencesRaw and experiences
const expRawIndex = this.experiencesRaw.findIndex(e => e.uuid === exp.uuid);
if (expRawIndex >= 0 && !this.utils.isEqual(this.experiencesRaw[expRawIndex].statistics, exp.statistics)) {
Expand Down

0 comments on commit 83a79af

Please sign in to comment.