Skip to content

Commit

Permalink
Merge pull request #715 from puzzle/main
Browse files Browse the repository at this point in the history
Adjust scoring to commit on 0.3 and target 0.7
  • Loading branch information
lkleisa authored Dec 13, 2023
2 parents 3eed66d + 54ddf7b commit 7346c0b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 86 deletions.
61 changes: 1 addition & 60 deletions .github/workflows/deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,68 +68,9 @@ jobs:
- name: print imagetags
run: echo ${{ needs.extract-version.outputs.okr-docker-image}}

e2e-docker:
runs-on: ubuntu-22.04
needs: [build-docker-image,extract-version]
steps:
- uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: okr-image
path: /tmp

- name: Load image
run: docker load --input /tmp/okr-docker-image.tar

- name: show images
run: docker image ls -a

- name: Run docker image
run: |
docker run --network=host \
-p 8080:8080 \
-e SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER-URI=http://localhost:8544/realms/pitc \
-e SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK-SET-URI=http://localhost:8544/realms/pitc/protocol/openid-connect/certs \
-e SPRING_SECURITY_OAUTH2_RESOURCESERVER_OPAQUETOKEN_CLIENT-ID=pitc_okr_staging \
-e SPRING_PROFILES_ACTIVE-ID=integration-test \
-e SPRING_DATASOURCE_URL="jdbc:h2:mem:db;DB_CLOSE_DELAY=-1" \
-e SPRING_DATASOURCE_USERNAME=user \
-e SPRING_DATASOURCE_PASSWORD=sa \
-e SPRING_FLYWAY_LOCATIONS="classpath:db/h2-db/database-h2-schema,classpath:db/h2-db/data-test-h2" \
${{ needs.extract-version.outputs.okr-docker-image}} &
- name: run keycloak docker
run: |
docker run \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=keycloak \
-v ./docker/config/realm-export.json:/opt/keycloak/data/import/realm.json \
-p 8544:8080 \
quay.io/keycloak/keycloak:23.0.1 \
start-dev --import-realm &
- uses: abhi1693/[email protected]
with:
browser: chrome
version: latest

- name: Cypress run e2e tests
uses: cypress-io/github-action@v6
with:
build: npm i -D cypress
install: false
wait-on: 'http://localhost:8080/config, http://localhost:8544'
wait-on-timeout: 120
browser: chrome
headed: true
working-directory: frontend
config: baseUrl=http://localhost:8080

okr-deploy:
runs-on: ubuntu-latest
needs: [e2e-docker, extract-version]
needs: [build-docker-image, extract-version]
steps:
- name: Checkout project
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>ch.puzzle.okr</groupId>
<artifactId>parent</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.0.5-SNAPSHOT</version>
</parent>

<artifactId>backend</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.0.5-SNAPSHOT</version>
<name>backend</name>
<description>Puzzle OKR Tool</description>

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/shared/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function optionalValue(param: object): { [p: string]: any } {
);
}
export function isInValid(baseline: number, stretchGoal: number, value: number): boolean {
if (value < baseline && baseline < stretchGoal) return true;
if (value < baseline && baseline <= stretchGoal) return true;
return value > baseline && baseline > stretchGoal;
}

Expand All @@ -44,6 +44,7 @@ export function calculateCurrentPercentage(keyResultMetric: KeyResultMetricMin):
let baseline: number = +keyResultMetric.baseline;
let stretchGoal: number = +keyResultMetric.stretchGoal;
if (isInValid(baseline, stretchGoal, value)) return 0;
if (value == stretchGoal) return 100;

return (Math.abs(value - baseline) / Math.abs(stretchGoal - baseline)) * 100;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ describe('ScoringComponent', () => {

it.each([
[{ fail: 0, commit: 0, target: 0, className: null, borderClass: 'none' }],
[{ fail: 100, commit: 0, target: 0, className: 'score-red', borderClass: 'fail' }],
[{ fail: 100, commit: 100, target: 0, className: 'score-yellow', borderClass: 'commit' }],
[{ fail: 99, commit: 0, target: 0, className: 'score-red', borderClass: 'fail' }],
[{ fail: 100, commit: 0, target: 0, className: 'score-yellow', borderClass: 'commit' }],
[{ fail: 100, commit: 99, target: 0, className: 'score-yellow', borderClass: 'commit' }],
[{ fail: 100, commit: 100, target: 0, className: 'score-green', borderClass: 'target' }],
[{ fail: 100, commit: 100, target: 99, className: 'score-green', borderClass: 'target' }],
[{ fail: 100, commit: 100, target: 100, className: 'score-green', borderClass: 'target' }],
[{ fail: 100, commit: 100, target: 101, className: 'score-stretch', borderClass: 'none' }],
])('should set styles correctly', async (object: any) => {
Expand Down
36 changes: 16 additions & 20 deletions frontend/src/app/shared/custom/scoring/scoring.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,31 @@ export class ScoringComponent implements OnInit, AfterViewInit, OnChanges {

let percentage = calculateCurrentPercentage(keyResultMetric);
this.labelPercentage = of(percentage);
switch (true) {
case percentage >= 100:
this.stretched = true;
break;
case percentage > 70:
this.stretched = false;
this.failPercent = 100;
this.commitPercent = 100;
this.targetPercent = (100 / 30) * (percentage - 70);
break;
case percentage > 30:
this.stretched = false;
this.failPercent = 100;
this.commitPercent = (100 / 40) * (percentage - 30);
break;
default:
this.stretched = false;
this.failPercent = (100 / 30) * percentage;
if (percentage < 30) {
this.stretched = false;
this.failPercent = (100 / 30) * percentage;
} else if (percentage < 70) {
this.stretched = false;
this.failPercent = 100;
this.commitPercent = (100 / 40) * (percentage - 30);
} else if (percentage < 100) {
this.stretched = false;
this.failPercent = 100;
this.commitPercent = 100;
this.targetPercent = (100 / 30) * (percentage - 70);
} else if (percentage >= 100) {
this.stretched = true;
}
}
}

getScoringColorClassAndSetBorder(): string | null {
if (this.targetPercent > 100) {
return 'score-stretch';
} else if (this.targetPercent > 0) {
} else if (this.targetPercent > 0 || (this.commitPercent == 100 && this.keyResult.keyResultType === 'metric')) {
this.setBorder(this.targetElement!);
return 'score-green';
} else if (this.commitPercent > 0) {
} else if (this.commitPercent > 0 || (this.failPercent == 100 && this.keyResult.keyResultType === 'metric')) {
this.setBorder(this.commitElement!);
return 'score-yellow';
} else if (this.failPercent > 0) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>ch.puzzle.okr</groupId>
<artifactId>parent</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.0.5-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down

0 comments on commit 7346c0b

Please sign in to comment.