Skip to content

feature: challenge update #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a124551
ci: deploy to dev
rakibansary Mar 21, 2023
c71e661
fix: use elasticsearch when opensearch-js is not availalbe
rakibansary Mar 21, 2023
f601c8c
Merge branch 'main' into feature/dev
rakibansary Mar 22, 2023
b4f7266
fix: project category id
rakibansary Mar 22, 2023
e459d3c
fix: project phase during challenge creation
rakibansary Mar 22, 2023
b285148
fix: scorecards to use
rakibansary Mar 22, 2023
356877c
fix: dev scorecard ids are different
rakibansary Mar 22, 2023
7f22886
chore: publish image
rakibansary Mar 22, 2023
b0d540e
fix: save creator
rakibansary Mar 22, 2023
e93dd65
fix: save createdBy and updatedBy
rakibansary Mar 22, 2023
b367154
fix: turn autopilot on
rakibansary Mar 22, 2023
bfa9d4e
update scorecard mapping (#16)
ThomasKranitsas Mar 22, 2023
fead91f
Feat/phase logic update (#17)
eisbilir Mar 23, 2023
fbb50d4
fix: bump versions
rakibansary Mar 23, 2023
92e9088
fix: fixed start time
eisbilir Mar 23, 2023
c24c1f7
fix: use uuid
rakibansary Mar 23, 2023
81144b6
Fix/sc (#19)
eisbilir Mar 23, 2023
d327656
wip: challenge updatge
rakibansary Mar 24, 2023
d1fd7c8
fix: non-null assertion
rakibansary Mar 24, 2023
af2d448
fix: improve handling of draft challenges
rakibansary Mar 24, 2023
344bf7f
fix: legacy challenge update
rakibansary Mar 24, 2023
24f5e72
fix: saving phase on challenge:update
rakibansary Mar 24, 2023
1488131
chore: remove logs
rakibansary Mar 24, 2023
21a6747
fix: remove undefined from map
rakibansary Mar 24, 2023
cdb45f4
fix: update to topcoder-interface v0.0.40
rakibansary Mar 25, 2023
d3acbba
feat: add logging interceptor
eisbilir Mar 25, 2023
40e7f28
fix: version bump
rakibansary Mar 25, 2023
4fe0db5
fix: do not call acl for v5 tasks
eisbilir Mar 25, 2023
0c35159
fix: add iterative review phase constraint
eisbilir Mar 25, 2023
5be22d7
fix: prize amount in cents
rakibansary Mar 26, 2023
70f8a19
fix: total prize calculation
rakibansary Mar 26, 2023
3e1b959
fix: prize calculation
rakibansary Mar 26, 2023
78dadbc
fix: post mortem flag
rakibansary Mar 26, 2023
a8dd9ae
fix: not creating ba in legacy
rakibansary Mar 26, 2023
593e1da
support delete challenge (#22)
ThomasKranitsas Mar 26, 2023
4eb266c
correct the f2f scorecard ID for dev (#23)
ThomasKranitsas Mar 26, 2023
aecdc66
fix typo in challenge.delete (#24)
ThomasKranitsas Mar 26, 2023
b387fd4
ci: publish image to prod ecr
rakibansary Mar 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
- image: cimg/aws:2023.01
environment:
CODEARTIFACT_ENV: PROD
ECR_ENV: QA
ECR_ENV: PROD
SERVICE_NAME: "domain-challenge"
OUT_DIR: "buildscripts"
steps:
Expand Down Expand Up @@ -48,5 +48,4 @@ workflows:
filters:
branches:
only:
- fix/update-pre-release
- main
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"printWidth": 100
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ ENV AUTH0_CLIENT_ID=""
ENV AUTH0_CLIENT_SECRET=""
ENV AUTH0_PROXY_SERVER_URL=""
ENV AUTH0_URL=""
ENV TOPCODER_API_URL=""

CMD ["server.js"]
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@
"@aws-sdk/util-utf8-node": "^3.259.0",
"@grpc/grpc-js": "^1.7.1",
"@opensearch-project/opensearch": "^2.2.0",
"@topcoder-framework/domain-acl": "^0.7.0",
"@topcoder-framework/lib-common": "^0.7.0",
"@topcoder-framework/domain-acl": "^0.10.13",
"@topcoder-framework/lib-common": "^0.10.13",
"@types/uuid": "^9.0.1",
"aws-sdk": "^2.1339.0",
"axios": "^1.2.2",
"dayjs": "^1.11.7",
"dotenv": "^16.0.3",
"elasticsearch": "^16.7.3",
"grpc-server-reflection": "^0.1.5",
"http-aws-es": "^6.0.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"source-map-support": "^0.5.21",
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6.4",
"topcoder-interface": "github:topcoder-platform/plat-interface-definition#v0.0.29",
"uuidv4": "^6.2.13",
"topcoder-interface": "github:topcoder-platform/plat-interface-definition#v0.0.46",
"uuid": "^9.0.0",
"xss": "^1.0.14"
},
"volta": {
Expand All @@ -43,6 +47,7 @@
"yarn": "1.22.19"
},
"devDependencies": {
"@types/elasticsearch": "^5.0.40",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.17",
"ts-node-dev": "^2.0.0",
Expand Down
9 changes: 3 additions & 6 deletions src/api/v5Api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const { V4_TECHNOLOGIES_API_URL, V4_PLATFORMS_API_URL, V4_CHALLENGE_API_URL } =
process.env;

import _ from "lodash";
import axios from "axios";

export const getRequest = async (url:string, token:string): Promise<any> => {
const res = await axios.get(url, { headers: { authorization: `Bearer ${token}` }})
export const getRequest = async (url: string, token: string): Promise<any> => {
const res = await axios.get(url, { headers: { authorization: `Bearer ${token}` } });
return res.data;
}
};
22 changes: 22 additions & 0 deletions src/common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,26 @@ export const ResourceInfoIds = {
export const ChallengeStatuses = {
New: "New",
Active: "Active",
Draft: "Draft",
};

export const PhaseTypeIds = {
Registration: 1,
Submission: 2,
Screening: 3,
Review: 4,
Appeals: 5,
AppealsResponse: 6,
Aggregation: 7,
AggregationReview: 8,
FinalFix: 9,
FinalReview: 10,
Approval: 11,
PostMortem: 12,
SpecificationSubmission: 13,
SpecificationReview: 14,
CheckpointSubmission: 15,
CheckpointScreening: 16,
CheckpointReview: 17,
IterativeReview: 18,
};
2 changes: 1 addition & 1 deletion src/common/ConversionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const V4_TRACKS = {
DESIGN: "DESIGN",
};

const V4_SUBTRACKS = {
export const V4_SUBTRACKS = {
MARATHON_MATCH: "MARATHON_MATCH",
DESIGN_FIRST_2_FINISH: "DESIGN_FIRST_2_FINISH",
APPLICATION_FRONT_END_DESIGN: "APPLICATION_FRONT_END_DESIGN",
Expand Down
51 changes: 22 additions & 29 deletions src/common/CoreOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import { noSqlClient } from "../dal/client/nosql";

// TODO: Import from @topcoder-framework/lib-common
import {
LookupCriteria,
ScanCriteria,
ScanResult,
} from "../models/common/common";
import { LookupCriteria, ScanCriteria, ScanResult } from "../models/common/common";

// TODO: Import from @topcoder-framework/lib-common
import { Value } from "../models/google/protobuf/struct";
Expand All @@ -25,7 +21,7 @@ import {
UpdateType,
Value as PartiQLValue,
} from "../dal/models/nosql/parti_ql";
import { StatusBuilder } from "@grpc/grpc-js";
import { Metadata, StatusBuilder } from "@grpc/grpc-js";
import { Status } from "@grpc/grpc-js/build/src/constants";

export type ValueType =
Expand All @@ -44,24 +40,20 @@ export type DynamoTableIndex = {
};
};

abstract class CoreOperations<
T extends { [key: string]: any },
I extends { [key: string]: any }
> {
abstract class CoreOperations<T extends { [key: string]: any }, I extends { [key: string]: any }> {
public constructor(
private entityName: string,
private entityAttributes: Attribute[],
private entityIndexList: DynamoTableIndex
) {}

private attributesKeyTypeMap: { [key: string]: DataType } =
this.entityAttributes.reduce(
(map, attribute) => ({
...map,
[attribute.name]: attribute.type,
}),
{}
);
private attributesKeyTypeMap: { [key: string]: DataType } = this.entityAttributes.reduce(
(map, attribute) => ({
...map,
[attribute.name]: attribute.type,
}),
{}
);

public async lookup(lookupCriteria: LookupCriteria): Promise<T> {
const selectQuery: SelectQuery = {
Expand Down Expand Up @@ -150,7 +142,7 @@ abstract class CoreOperations<
};
}

protected async create(entity: I & T): Promise<T> {
protected async create(entity: I & T, metadata?: Metadata): Promise<T> {
const queryRequest: QueryRequest = {
kind: {
$case: "query",
Expand All @@ -177,7 +169,8 @@ abstract class CoreOperations<

public async update(
scanCriteria: ScanCriteria[],
entity: unknown
entity: unknown,
metadata?: Metadata
): Promise<{ items: T[] }> {
if (typeof entity != "object" || entity == null) {
throw new Error("Expected key-value pairs to update");
Expand All @@ -193,12 +186,14 @@ abstract class CoreOperations<
update: {
table: this.entityName,
// TODO: Write a convenience method in @topcoder-framework/lib-common to support additional update operations like LIST_APPEND, SET_ADD, SET_REMOVE, etc
updates: Object.entries(entity).map(([key, value]) => ({
action: UpdateAction.UPDATE_ACTION_SET,
type: UpdateType.UPDATE_TYPE_VALUE,
attribute: key,
value: this.toValue(key, value),
})),
updates: Object.entries(entity)
.filter(([key, value]) => value !== undefined)
.map(([key, value]) => ({
action: UpdateAction.UPDATE_ACTION_SET,
type: UpdateType.UPDATE_TYPE_VALUE,
attribute: key,
value: this.toValue(key, value),
})),
filters,
returnValue: ReturnValue.RETURN_VALUE_ALL_NEW,
},
Expand Down Expand Up @@ -330,9 +325,7 @@ abstract class CoreOperations<
break;

default:
throw new Error(
"Lookups are only supported for string, number & boolean value"
);
throw new Error("Lookups are only supported for string, number & boolean value");
}

return value;
Expand Down
88 changes: 66 additions & 22 deletions src/dal/models/nosql/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,20 @@ export const Struct = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 10) {
break;
}

const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
if (entry1.value !== undefined) {
message.fields[entry1.key] = entry1.value;
}
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down Expand Up @@ -209,15 +214,24 @@ export const Struct_FieldsEntry = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 10) {
break;
}

message.key = reader.string();
break;
continue;
case 2:
if (tag != 18) {
break;
}

message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down Expand Up @@ -282,27 +296,52 @@ export const Value = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 8) {
break;
}

message.kind = { $case: "nullValue", nullValue: nullValueFromJSON(reader.int32()) };
break;
continue;
case 2:
if (tag != 17) {
break;
}

message.kind = { $case: "numberValue", numberValue: reader.double() };
break;
continue;
case 3:
if (tag != 26) {
break;
}

message.kind = { $case: "stringValue", stringValue: reader.string() };
break;
continue;
case 4:
if (tag != 32) {
break;
}

message.kind = { $case: "boolValue", boolValue: reader.bool() };
break;
continue;
case 5:
if (tag != 42) {
break;
}

message.kind = { $case: "structValue", structValue: Struct.unwrap(Struct.decode(reader, reader.uint32())) };
break;
continue;
case 6:
if (tag != 50) {
break;
}

message.kind = { $case: "listValue", listValue: ListValue.unwrap(ListValue.decode(reader, reader.uint32())) };
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down Expand Up @@ -435,12 +474,17 @@ export const ListValue = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 10) {
break;
}

message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down
Loading