Skip to content

Commit 0abf291

Browse files
committed
new web based analysis
1 parent bed01ae commit 0abf291

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2658
-72
lines changed

.github/workflows/gh-pages.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
2+
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Build job
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
- name: Setup Pages
32+
uses: actions/configure-pages@v3
33+
- name: Build
34+
run: |
35+
cd analysis/v2ex-analysis
36+
pnpm install
37+
pnpm build
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v1
40+
with:
41+
path: "analysis/v2ex-analysis/dist"
42+
# Deployment job
43+
deploy:
44+
environment:
45+
name: github-pages
46+
url: ${{ steps.deployment.outputs.page_url }}
47+
runs-on: ubuntu-latest
48+
needs: build
49+
steps:
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v2

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161-
filename.html
162-
reply_oldshensheep.json
163-
v2ex.json
164-
v2ex.sqlite
161+
165162
.vscode/settings.json
163+
*.7z
164+
*.sqlite

analysis.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

analysis/main.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import pandas
2+
import sqlite3
3+
4+
5+
conn = sqlite3.connect("v2ex.sqlite")
6+
7+
e = {
8+
"top-comment": """
9+
select topic_id, c.id, c.content, c.thank_count, c.no, t.title
10+
from comment c
11+
left join topic t on t.id = c.topic_id
12+
order by c.thank_count desc
13+
""",
14+
"top-topic-by-thank_count": """
15+
select id, title, thank_count
16+
from topic
17+
order by thank_count desc
18+
""",
19+
"top-topic-by-favorite_count": """
20+
select id, title, favorite_count
21+
from topic
22+
order by favorite_count desc
23+
""",
24+
"top-topic-by-votes": """
25+
select id, title, votes
26+
from topic
27+
order by votes desc
28+
""",
29+
"top-topic-by-clicks": """
30+
select id, title, clicks
31+
from topic
32+
order by clicks desc
33+
""",
34+
"tag-usage-count": """
35+
select t.value as tag, count(*) as count
36+
from topic,
37+
json_each(tag) as t
38+
group by t.value
39+
order by count desc
40+
""",
41+
"top-user-by-comment_count": """
42+
select commenter as username, count(commenter) as comment_count
43+
from comment
44+
group by commenter
45+
order by comment_count desc
46+
""",
47+
"top-user-by-topic_count": """
48+
select author as username, count(author) as topic_count
49+
from topic
50+
group by author
51+
order by topic_count desc
52+
""",
53+
}
54+
e2 = {
55+
"new-topic-every-month": """
56+
SELECT strftime('%Y-%m', create_at, 'unixepoch') AS date, COUNT(*) AS topic_count
57+
FROM topic
58+
GROUP BY date
59+
""",
60+
"new-comment-every-month": """
61+
SELECT strftime('%Y-%m', create_at, 'unixepoch') AS date, COUNT(*) AS comment_count
62+
FROM comment
63+
GROUP BY date
64+
""",
65+
"new-member-every-month": """
66+
SELECT strftime('%Y-%m', create_at, 'unixepoch') AS date, COUNT(*) AS member_count
67+
FROM member
68+
GROUP BY date
69+
""",
70+
}
71+
LIMIT = 20
72+
73+
74+
def f(
75+
sql: str,
76+
export_name: str,
77+
conn,
78+
limit: int | None = LIMIT,
79+
orient: str | None = "records",
80+
):
81+
ae = "" if limit is None else f" limit {limit}"
82+
pandas.read_sql(f"{sql} {ae}", conn).to_json(
83+
f"./analysis/v2ex-analysis/public/{export_name}.json",
84+
force_ascii=False,
85+
orient=orient,
86+
)
87+
88+
89+
for i, sql in e.items():
90+
f(sql=sql, export_name=i, conn=conn)
91+
for i, sql in e2.items():
92+
f(sql=sql, export_name=i, conn=conn, limit=None, orient=None)

analysis/v2ex-analysis/.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
/cypress/videos/
18+
/cypress/screenshots/
19+
20+
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
23+
.idea
24+
*.suo
25+
*.ntvs*
26+
*.njsproj
27+
*.sln
28+
*.sw?

analysis/v2ex-analysis/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# v2ex-analysis
2+
3+
This template should help get you started developing with Vue 3 in Vite.
4+
5+
## Recommended IDE Setup
6+
7+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
8+
9+
## Type Support for `.vue` Imports in TS
10+
11+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
12+
13+
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
14+
15+
1. Disable the built-in TypeScript Extension
16+
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
17+
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
18+
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
19+
20+
## Customize configuration
21+
22+
See [Vite Configuration Reference](https://vitejs.dev/config/).
23+
24+
## Project Setup
25+
26+
```sh
27+
npm install
28+
```
29+
30+
### Compile and Hot-Reload for Development
31+
32+
```sh
33+
npm run dev
34+
```
35+
36+
### Type-Check, Compile and Minify for Production
37+
38+
```sh
39+
npm run build
40+
```

analysis/v2ex-analysis/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

analysis/v2ex-analysis/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<link rel="icon" href="/favicon.ico">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Vite App</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

analysis/v2ex-analysis/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "v2ex-analysis",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "run-p type-check build-only",
8+
"preview": "vite preview",
9+
"build-only": "vite build",
10+
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
11+
},
12+
"dependencies": {
13+
"plotly.js-dist-min": "^2.24.3",
14+
"vue": "^3.3.4"
15+
},
16+
"devDependencies": {
17+
"@tsconfig/node18": "^2.0.1",
18+
"@types/node": "^18.16.17",
19+
"@vitejs/plugin-vue": "^4.2.3",
20+
"@vue/tsconfig": "^0.4.0",
21+
"autoprefixer": "^10.4.14",
22+
"daisyui": "^3.2.1",
23+
"npm-run-all": "^4.1.5",
24+
"postcss": "^8.4.25",
25+
"tailwindcss": "^3.3.2",
26+
"typescript": "~5.0.4",
27+
"vite": "^4.3.9",
28+
"vue-tsc": "^1.6.5"
29+
}
30+
}

0 commit comments

Comments
 (0)