Skip to content

Commit 7346c0b

Browse files
authored
Merge pull request #715 from puzzle/main
Adjust scoring to commit on 0.3 and target 0.7
2 parents 3eed66d + 54ddf7b commit 7346c0b

File tree

6 files changed

+27
-86
lines changed

6 files changed

+27
-86
lines changed

.github/workflows/deploy-action.yml

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -68,68 +68,9 @@ jobs:
6868
- name: print imagetags
6969
run: echo ${{ needs.extract-version.outputs.okr-docker-image}}
7070

71-
e2e-docker:
72-
runs-on: ubuntu-22.04
73-
needs: [build-docker-image,extract-version]
74-
steps:
75-
- uses: actions/checkout@v4
76-
77-
- name: Download artifact
78-
uses: actions/download-artifact@v3
79-
with:
80-
name: okr-image
81-
path: /tmp
82-
83-
- name: Load image
84-
run: docker load --input /tmp/okr-docker-image.tar
85-
86-
- name: show images
87-
run: docker image ls -a
88-
89-
- name: Run docker image
90-
run: |
91-
docker run --network=host \
92-
-p 8080:8080 \
93-
-e SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER-URI=http://localhost:8544/realms/pitc \
94-
-e SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK-SET-URI=http://localhost:8544/realms/pitc/protocol/openid-connect/certs \
95-
-e SPRING_SECURITY_OAUTH2_RESOURCESERVER_OPAQUETOKEN_CLIENT-ID=pitc_okr_staging \
96-
-e SPRING_PROFILES_ACTIVE-ID=integration-test \
97-
-e SPRING_DATASOURCE_URL="jdbc:h2:mem:db;DB_CLOSE_DELAY=-1" \
98-
-e SPRING_DATASOURCE_USERNAME=user \
99-
-e SPRING_DATASOURCE_PASSWORD=sa \
100-
-e SPRING_FLYWAY_LOCATIONS="classpath:db/h2-db/database-h2-schema,classpath:db/h2-db/data-test-h2" \
101-
${{ needs.extract-version.outputs.okr-docker-image}} &
102-
103-
- name: run keycloak docker
104-
run: |
105-
docker run \
106-
-e KEYCLOAK_ADMIN=admin \
107-
-e KEYCLOAK_ADMIN_PASSWORD=keycloak \
108-
-v ./docker/config/realm-export.json:/opt/keycloak/data/import/realm.json \
109-
-p 8544:8080 \
110-
quay.io/keycloak/keycloak:23.0.1 \
111-
start-dev --import-realm &
112-
113-
- uses: abhi1693/setup-browser@v0.3.5
114-
with:
115-
browser: chrome
116-
version: latest
117-
118-
- name: Cypress run e2e tests
119-
uses: cypress-io/github-action@v6
120-
with:
121-
build: npm i -D cypress
122-
install: false
123-
wait-on: 'http://localhost:8080/config, http://localhost:8544'
124-
wait-on-timeout: 120
125-
browser: chrome
126-
headed: true
127-
working-directory: frontend
128-
config: baseUrl=http://localhost:8080
129-
13071
okr-deploy:
13172
runs-on: ubuntu-latest
132-
needs: [e2e-docker, extract-version]
73+
needs: [build-docker-image, extract-version]
13374
steps:
13475
- name: Checkout project
13576
uses: actions/checkout@v4

backend/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<parent>
77
<groupId>ch.puzzle.okr</groupId>
88
<artifactId>parent</artifactId>
9-
<version>2.0.4-SNAPSHOT</version>
9+
<version>2.0.5-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>backend</artifactId>
13-
<version>2.0.4-SNAPSHOT</version>
13+
<version>2.0.5-SNAPSHOT</version>
1414
<name>backend</name>
1515
<description>Puzzle OKR Tool</description>
1616

frontend/src/app/shared/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function optionalValue(param: object): { [p: string]: any } {
3535
);
3636
}
3737
export function isInValid(baseline: number, stretchGoal: number, value: number): boolean {
38-
if (value < baseline && baseline < stretchGoal) return true;
38+
if (value < baseline && baseline <= stretchGoal) return true;
3939
return value > baseline && baseline > stretchGoal;
4040
}
4141

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

4849
return (Math.abs(value - baseline) / Math.abs(stretchGoal - baseline)) * 100;
4950
}

frontend/src/app/shared/custom/scoring/scoring.component.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ describe('ScoringComponent', () => {
4343

4444
it.each([
4545
[{ fail: 0, commit: 0, target: 0, className: null, borderClass: 'none' }],
46-
[{ fail: 100, commit: 0, target: 0, className: 'score-red', borderClass: 'fail' }],
47-
[{ fail: 100, commit: 100, target: 0, className: 'score-yellow', borderClass: 'commit' }],
46+
[{ fail: 99, commit: 0, target: 0, className: 'score-red', borderClass: 'fail' }],
47+
[{ fail: 100, commit: 0, target: 0, className: 'score-yellow', borderClass: 'commit' }],
48+
[{ fail: 100, commit: 99, target: 0, className: 'score-yellow', borderClass: 'commit' }],
49+
[{ fail: 100, commit: 100, target: 0, className: 'score-green', borderClass: 'target' }],
50+
[{ fail: 100, commit: 100, target: 99, className: 'score-green', borderClass: 'target' }],
4851
[{ fail: 100, commit: 100, target: 100, className: 'score-green', borderClass: 'target' }],
4952
[{ fail: 100, commit: 100, target: 101, className: 'score-stretch', borderClass: 'none' }],
5053
])('should set styles correctly', async (object: any) => {

frontend/src/app/shared/custom/scoring/scoring.component.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,35 +113,31 @@ export class ScoringComponent implements OnInit, AfterViewInit, OnChanges {
113113

114114
let percentage = calculateCurrentPercentage(keyResultMetric);
115115
this.labelPercentage = of(percentage);
116-
switch (true) {
117-
case percentage >= 100:
118-
this.stretched = true;
119-
break;
120-
case percentage > 70:
121-
this.stretched = false;
122-
this.failPercent = 100;
123-
this.commitPercent = 100;
124-
this.targetPercent = (100 / 30) * (percentage - 70);
125-
break;
126-
case percentage > 30:
127-
this.stretched = false;
128-
this.failPercent = 100;
129-
this.commitPercent = (100 / 40) * (percentage - 30);
130-
break;
131-
default:
132-
this.stretched = false;
133-
this.failPercent = (100 / 30) * percentage;
116+
if (percentage < 30) {
117+
this.stretched = false;
118+
this.failPercent = (100 / 30) * percentage;
119+
} else if (percentage < 70) {
120+
this.stretched = false;
121+
this.failPercent = 100;
122+
this.commitPercent = (100 / 40) * (percentage - 30);
123+
} else if (percentage < 100) {
124+
this.stretched = false;
125+
this.failPercent = 100;
126+
this.commitPercent = 100;
127+
this.targetPercent = (100 / 30) * (percentage - 70);
128+
} else if (percentage >= 100) {
129+
this.stretched = true;
134130
}
135131
}
136132
}
137133

138134
getScoringColorClassAndSetBorder(): string | null {
139135
if (this.targetPercent > 100) {
140136
return 'score-stretch';
141-
} else if (this.targetPercent > 0) {
137+
} else if (this.targetPercent > 0 || (this.commitPercent == 100 && this.keyResult.keyResultType === 'metric')) {
142138
this.setBorder(this.targetElement!);
143139
return 'score-green';
144-
} else if (this.commitPercent > 0) {
140+
} else if (this.commitPercent > 0 || (this.failPercent == 100 && this.keyResult.keyResultType === 'metric')) {
145141
this.setBorder(this.commitElement!);
146142
return 'score-yellow';
147143
} else if (this.failPercent > 0) {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>ch.puzzle.okr</groupId>
1010
<artifactId>parent</artifactId>
11-
<version>2.0.4-SNAPSHOT</version>
11+
<version>2.0.5-SNAPSHOT</version>
1212

1313
<parent>
1414
<groupId>org.springframework.boot</groupId>

0 commit comments

Comments
 (0)