Skip to content

Commit 1133121

Browse files
committed
feat: add statistics
1 parent b081874 commit 1133121

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.husky/pre-commit

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run format
4+
npx --no-install lint-staged
5+

util/crawl_leetcode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Sequelize from 'sequelize'
33
import * as path from 'path'
44
import async from 'async'
55

6-
const sequelize = new Sequelize.Sequelize('leetcode', 'null', 'null', {
6+
export const sequelize = new Sequelize.Sequelize('leetcode', 'null', 'null', {
77
dialect: 'sqlite',
88
define: {
99
timestamps: true,

util/leetcode.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { extract_rust_solution, underline } from './utils'
2+
import { sequelize } from './crawl_leetcode'
23

34
test('test underline filename', () => {
45
const a = underline('minimum-swaps-to-group-all-1s-together')
@@ -24,3 +25,14 @@ test('reference test', () => {
2425
append_str(o)
2526
console.log(o)
2627
})
28+
29+
test('leetcode statistics', async () => {
30+
const r = await sequelize.query(
31+
`select difficulty, count(*) from leetcode group by difficulty;`,
32+
)
33+
console.log(`easy medium hard`, r[0])
34+
const paidCount = await sequelize.query(
35+
`select count(*) from leetcode where paidOnly == 1;`,
36+
)
37+
console.log(`paid count`, paidCount[0])
38+
})

0 commit comments

Comments
 (0)