Skip to content

Commit 25a6338

Browse files
committed
feat: add filter method for problems
1 parent 68507b1 commit 25a6338

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

util/leetcode.test.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { extract_rust_solution, underline } from './utils'
2-
import { sequelize } from './crawl_leetcode'
2+
import { Problem, sequelize } from './crawl_leetcode'
3+
import { generatePool, JSconfig } from './pools_utils'
34

45
test('test underline filename', () => {
56
const a = underline('minimum-swaps-to-group-all-1s-together')
@@ -36,3 +37,16 @@ test('leetcode statistics', async () => {
3637
)
3738
console.log(`paid count`, paidCount[0])
3839
})
40+
41+
test('generate special', async () => {
42+
const r = await Problem.findAll({
43+
where: {
44+
frontend_id: 141,
45+
},
46+
})
47+
48+
await generatePool({
49+
problems: r,
50+
config: JSconfig,
51+
})
52+
})

util/pools_utils.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const JSconfig: CodeConfig = {
2727
getCode: (c) => c.find((a) => a.value === 'javascript').defaultCode,
2828
ext: 'js',
2929
comment: '//',
30-
fileNameStyle: (s) => s.replace(/[\s|?]/g, ''),
30+
fileNameStyle: (s, i) => `_${i.toString().padStart(4, '0')}_${underline(s)}`,
3131
}
3232

3333
export const Goconfig: CodeConfig = {
@@ -131,8 +131,3 @@ export async function generatePool({
131131
})
132132
})
133133
}
134-
135-
console.log('generate pools finished')
136-
let test = false
137-
process.argv.includes('--test') && (test = true)
138-
// generatePool({ config: Rust, test: test }).catch(console.error)

0 commit comments

Comments
 (0)