Skip to content

Commit 6719ff0

Browse files
committedJun 19, 2020
feat(client): challs sort weight
1 parent 1799b82 commit 6719ff0

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed
 

‎client/src/routes/challs.js

+11
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ const Challenges = ({ classes }) => {
103103
}
104104
})
105105
}
106+
107+
filtered.sort((a, b) => {
108+
if (a.points === b.points) {
109+
const aWeight = a.sortWeight || 0
110+
const bWeight = b.sortWeight || 0
111+
112+
return bWeight - aWeight
113+
}
114+
return a.points - b.points
115+
})
116+
106117
return filtered
107118
}, [problems, categories, showSolved, solveIDs])
108119

‎preact.config.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ export default (config, env, helpers) => {
1111
// Disable sourcemaps
1212
config.devtool = false
1313
} else {
14-
config.devServer.proxy = {
15-
'/api': 'http://localhost:3000'
16-
}
14+
config.devServer.proxy = [{
15+
path: '/api/**',
16+
target: 'http://localhost:3000',
17+
changeOrigin: true,
18+
changeHost: true
19+
}]
1720
}
1821

1922
config.resolveLoader.modules.unshift(path.resolve(__dirname, 'client/lib/loaders'))

‎server/challenges/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let challengesMap: Map<string, Challenge> = new Map()
1313
let cleanedChallengesMap: Map<string, CleanedChallenge> = new Map()
1414

1515
const cleanChallenge = (chall: Challenge): CleanedChallenge => {
16-
const { files, description, author, points, id, name, category } = chall
16+
const { files, description, author, points, id, name, category, sortWeight } = chall
1717

1818
return {
1919
files,
@@ -22,7 +22,8 @@ const cleanChallenge = (chall: Challenge): CleanedChallenge => {
2222
points,
2323
id,
2424
name,
25-
category
25+
category,
26+
sortWeight
2627
}
2728
}
2829

‎server/challenges/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface CleanedChallenge {
1616
author: string;
1717
files: File[];
1818
points: Points;
19+
sortWeight?: number;
1920
}
2021

2122
export interface Challenge {
@@ -28,4 +29,5 @@ export interface Challenge {
2829
points: Points;
2930
flag: string;
3031
tiebreakEligible: boolean;
32+
sortWeight?: number;
3133
}

‎server/providers/challenges/rdeploy-blob/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface RDeployChallenge {
2525
points: Points;
2626
flag: string;
2727
tiebreakEligible: boolean;
28+
sortWeight?: number;
2829
}
2930

3031
class RDeployBlobProvider extends EventEmitter implements Provider {

0 commit comments

Comments
 (0)