Skip to content
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

merge develop into main #31

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
868d665
Add 20211, 20212 table and Fix chrome driver binary version
karintou8710 Feb 9, 2022
1397452
Refactor loadalldata command and add some tests.
karintou8710 Feb 12, 2022
659c12b
small fix
karintou8710 Feb 12, 2022
97f034d
Merge branch 'master' into develop
karintou8710 Feb 12, 2022
bc36371
セッションの有効期限を6年に変更
ojizosan Feb 14, 2022
627691e
Merge pull request #26 from ojizosan/develop
karintou8710 Feb 14, 2022
4cb55a8
Add comment
karintou8710 Mar 12, 2022
a10fb54
Clean bookmark view code
karintou8710 Mar 12, 2022
9dfaecd
Add error handlinf of axios and fix bookmark bug
karintou8710 Mar 12, 2022
0503c40
Merge pull request #28 from karintou8710/refactoring
karintou8710 Mar 12, 2022
76e8003
[fix] update scraping table
karintou8710 Dec 19, 2022
c8a61bd
[fix] use auto-update chromedriver
karintou8710 Dec 19, 2022
5c7f8a7
[fix] fix invalid gradeurl
karintou8710 Dec 19, 2022
10a7d52
[fix] deploy command
karintou8710 Aug 20, 2023
0669b5a
Merge remote-tracking branch 'refs/remotes/origin/develop' into develop
karintou8710 Aug 20, 2023
cd8ad35
[chore] upgrade webdriver-manager
karintou8710 Dec 9, 2023
e667f34
[fix] recursive mkdir
karintou8710 Dec 9, 2023
f58f6e1
[doc] update README
karintou8710 Dec 9, 2023
ebfd4b5
[fix] 新GPAのみの行に対応
karintou8710 Jul 11, 2024
101b0b5
[format] lintエラーの修正
karintou8710 Jul 11, 2024
5e57f90
Merge pull request #33 from JagaJagaHU/bug/#32_single_line
karintou8710 Jul 11, 2024
e63a08e
chore: upgrade selenium v4
karintou8710 Dec 13, 2024
7b4c64a
fix: selenium v4 api
karintou8710 Dec 13, 2024
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
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,43 @@ iNAZO とは北大が公開している成績データを見やすく纏めた W

## Local Usage

./clientでの作業
```
./client での作業

```bash
yarn install
yarn dev
```

./serverでの作業
```
./server での作業

```bash
pipenv sync
cp .env.example .env
```
.envのDATABASE_URLを絶対パスで適切に設定する

.env の DATABASE_URL を絶対パスで適切に設定する
example: sqlite:////tmp/my-tmp-sqlite.db
```

```bash
pipenv run migrate
pipenv run dev
```

初期データは別途スクレイピングをしてDBに保存してください。
初期データは別途スクレイピングをして DB に保存してください。

## スクレイピング方法

```bash
pipenv run gradescraping <year-semester> <faculty>
# example
pipenv run gradescraping 2023 1
```

成績を DB にロードする

```bash
pipenv run loaddata
```

## Source

Expand All @@ -44,11 +62,9 @@ http://educate.academic.hokudai.ac.jp/seiseki/GradeDistSerch.aspx

## Relevant repository

OGP IMAGEを動的に生成するツール
OGP IMAGE を動的に生成するツール
[iNAZO-opg-image](https://github.com/karintou8710/iNAZO-ogp-image)

## License

このプロジェクトは [MIT license](https://en.wikipedia.org/wiki/MIT_License) です。


1 change: 1 addition & 0 deletions client/layouts/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</template>
<template v-else>
<h1>An error occurred</h1>
<p>status code: {{ error.statusCode }}</p>
<p>{{ error.message }}</p>
</template>
</v-col>
Expand Down
67 changes: 58 additions & 9 deletions client/mixins/chart-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,77 @@ export default {

if (item.isBookMark) {
// ブックマーク解除
const res = await axios.delete(`${bookmarkURL}${bookMarkID}/`, {
withCredentials: true
});
let res;
try {
res = await axios.delete(`${bookmarkURL}${bookMarkID}/`, {
withCredentials: true
});
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
return;
}

if (res.status === HTTP_204_NO_CONTENT) {
this.bookMarkIDs = this.bookMarkIDs.filter(id => id !== bookMarkID);
item.isBookMark = !item.isBookMark;
this.$set(this.items, index, item);
} else {
this.$nuxt.error({
status: res.status,
message: '予期しないステータスコードです'
});
}
} else {
// 登録
const res = await axios.post(
bookmarkURL,
{ bookMarkID },
{
withCredentials: true
let res;
try {
res = await axios.post(
bookmarkURL,
{ bookMarkID },
{
withCredentials: true
}
);
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
);
return;
}

if (res.status === HTTP_201_CREATED) {
this.bookMarkIDs = res.data.bookMarkIDs;
item.isBookMark = !item.isBookMark;
this.$set(this.items, index, item);
} else {
this.$nuxt.error({
status: res.status,
message: '予期しないステータスコードです'
});
}
}
},
Expand Down
25 changes: 22 additions & 3 deletions client/pages/bookmark.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,28 @@ export default {
async fetchBookmarkAPIData () {
this.isVisible = false;

const res = await axios.get(this.joinQuery(bookmarkURL), {
withCredentials: true
});
let res;
try {
res = await axios.get(this.joinQuery(bookmarkURL), {
withCredentials: true
});
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
return;
}

this.items.splice(0, this.items.length);
this.items.push(...res.data);
Expand Down
143 changes: 119 additions & 24 deletions client/pages/detail/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ export default {
},
async fetch () {
await this.fetchGradeAPIData();

if (process.server) {
const headers = this.$nuxt.context.req.headers;
await this.fetchBookmarkAPIData(headers);
} else {
await this.fetchBookmarkAPIData();
}
},
head () {
return {
Expand Down Expand Up @@ -146,10 +153,6 @@ export default {
return url;
}
},
async mounted () {
// 初期取得はbookmarkを始めにfetchする。
await this.fetchBookmarkAPIdata();
},
methods: {
filterSearch () {
this.$router.push({ path: `/search/?search=${this.search}` });
Expand All @@ -158,9 +161,28 @@ export default {
async fetchGradeAPIData () {
this.isVisible = false;

const res = await axios.get(gradeURL + this.$route.params.id, {
withCredentials: true
});
let res;
try {
res = await axios.get(gradeURL + this.$route.params.id, {
withCredentials: true
});
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
return;
}

// chartを更新
this.items.push(res.data);
Expand Down Expand Up @@ -193,45 +215,118 @@ export default {
this.isVisible = true;
},

// ページに訪れた時のみに使用
async fetchBookmarkAPIdata () {
const res = await axios.get(bookmarkURL, {
withCredentials: true
});
this.bookMarkIDs = res.data.map(item => item.id);
},

async postBookMark (index) {
// Objectをコピーする必要がある。
const item = Object.assign({}, this.items[index]);
const bookMarkID = item.id;

if (item.isBookMark) {
// ブックマーク解除
const res = await axios.delete(`${bookmarkURL}${bookMarkID}/`, {
withCredentials: true
});
let res;
try {
res = await axios.delete(`${bookmarkURL}${bookMarkID}/`, {
withCredentials: true
});
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
return;
}

if (res.status === HTTP_204_NO_CONTENT) {
this.bookMarkIDs = this.bookMarkIDs.filter(id => id !== bookMarkID);
item.isBookMark = !item.isBookMark;
this.$set(this.items, index, item);
} else {
this.$nuxt.error({
status: res.status,
message: '予期しないステータスコードです'
});
}
} else {
// 登録
const res = await axios.post(
bookmarkURL,
{ bookMarkID },
{
withCredentials: true
let res;
try {
res = await axios.post(
bookmarkURL,
{ bookMarkID },
{
withCredentials: true
}
);
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
);
return;
}

if (res.status === HTTP_201_CREATED) {
this.bookMarkIDs = res.data.bookMarkIDs;
item.isBookMark = !item.isBookMark;
this.$set(this.items, index, item);
} else {
this.$nuxt.error({
status: res.status,
message: '予期しないステータスコードです'
});
}
}
},

// ページに訪れた時のみに使用
async fetchBookmarkAPIData (headers) {
const options = {
withCredentials: true
};
if (headers) { options.headers = { cookie: headers.cookie }; }
let res;
try {
res = await axios.get(bookmarkURL, options);
} catch (error) {
if (error.response) {
this.$nuxt.error({
status: error.response.status,
message: 'サーバーでエラーが発生しました'
});
} else if (error.request) {
this.$nuxt.error({
message: 'サーバーからレスポンスがありません'
});
} else {
this.$nuxt.error({
message: error.message
});
}
return;
}
this.bookMarkIDs = res.data.map(item => item.id);
this.items.forEach((item) => {
this.$set(item, 'isBookMark', this.bookMarkIDs.includes(item.id));
});
}
}
};
Expand Down
Loading
Loading