Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/gin-contrib…
Browse files Browse the repository at this point in the history
…/zap-0.1.0

# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
runs committed Feb 16, 2023
2 parents b778839 + 95047d0 commit bfdf3fe
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 18 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '34 18 * * 4'
workflow_dispatch:

jobs:
analyze:
name: Analyze
runs-on: [ self-hosted ]
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version-file: './go.mod'
cache-dependency-path: './go.sum'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/eoefans-api-azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

runs-on: [self-hosted, Linux]
environment:
name: 'Production'
name: 'Production-API'
# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/eoefans-spider-azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

runs-on: [self-hosted, Linux]
environment:
name: 'Production'
name: 'Production-SPIDER'
# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# eoefans-api
[![EOEFANS-API-DOCKER-CI](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-api-docker-ci.yml/badge.svg)](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-api-docker-ci.yml)
[![EOEFANS-SPIDER-DOCKER-CI](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-spider-docker-ci.yml/badge.svg)](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-spider-docker-ci.yml)

[![EOEFANS-API-AZURE-DEPLOY](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-api-azure-deploy.yml/badge.svg)](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-api-azure-deploy.yml)
[![EOEFANS-SPIDER-AZURE-DEPLOY](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-spider-azure-deploy.yml/badge.svg)](https://vlink.dev/EOEFANS/eoefans-api/actions/workflows/eoefans-spider-azure-deploy.yml)


eoefans api支持

Expand All @@ -7,11 +13,13 @@ eoefans api支持
- [全球访问](https://portal.api.eoe.best/api-details#api=eoefans-api)

## 使用指南
```Main```分支打tag后自动构建。tag规格:```v*.*.*```
- Dependabot每周五上午09点自动检查```Main```分支的依赖。请及时查看Dependabot开启的[PR](https://vlink.dev/EOEFANS/eoefans-api/pulls?q=is%3Apr+is%3Aopen+label%3Adependencies)并根据需要合并。若PR开启的节点较为落后,可使用```@dependabot rebase```回复相应PR([示例](https://vlink.dev/EOEFANS/eoefans-api/pull/9#issuecomment-10)),让bot重新提交Commit。

- ```Main```分支打tag后自动构建。tag规格:```v*.*.*```

构建后的镜像可在[组织镜像页面](https://vlink.dev/orgs/EOEFANS/packages)或右侧```Packages```查看。
- 构建后的镜像可在[组织镜像页面](https://vlink.dev/orgs/EOEFANS/packages)或右侧```Packages```查看。这步不是必须的,不过最好在部署前手动确认最新版镜像已经发布

需要部署的话,请将 ```Main``` 提起PR至 ```release``` 分支,后合并入 ```release``` 分支。部署将自动排队并等待手动通过。请前往 [Actioins](https://vlink.dev/EOEFANS/eoefans-api/actions) 审阅。手动通过相关部署后,部署即可完成。
- 需要部署的话,请将 ```Main``` 提起PR至 ```release``` 分支,后合并入 ```release``` 分支。部署将自动排队并等待手动通过。请前往 [Actioins](https://vlink.dev/EOEFANS/eoefans-api/actions) 审阅。手动通过相关部署后,部署即可完成。

## 环境

Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.18

require (
github.com/gin-contrib/zap v0.1.0
github.com/gin-gonic/gin v1.8.1
github.com/go-playground/validator/v10 v10.10.1
github.com/gin-gonic/gin v1.8.2
github.com/go-playground/validator/v10 v10.11.1
github.com/go-resty/resty/v2 v2.7.0
github.com/google/uuid v1.3.0
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
Expand All @@ -26,19 +26,19 @@ require (
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -51,10 +51,10 @@ require (
go.uber.org/dig v1.14.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
1 change: 1 addition & 0 deletions internal/app/api/idl/bilibili_picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
Uncomfortable DynamicFeedback = 4 //不适宜的内容
)

var DynamicFeedbackVec = []DynamicFeedback{Default, IncorrectTags, OnPeriod}
var DynamicFeedbackMap = map[DynamicFeedback]struct{}{
Default: {},
Unrelated: {},
Expand Down
8 changes: 4 additions & 4 deletions internal/repository/bilibili_picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (impl *BilibiliPictureMysqlImpl) Latest(page, size, topicID int) (list []*i
err = conn.Where("pictures_num > 0").Select("dynamic_id,sent_at").
Order("sent_at DESC").
Offset(offset).
Limit(size).Preload("Pics", "feedback = ?", 0).Find(&list).Error
Limit(size).Preload("Pics", "feedback in (?)", idl.DynamicFeedbackVec).Find(&list).Error
if err != nil {
return nil, err
}
Expand All @@ -128,7 +128,7 @@ func (impl *BilibiliPictureMysqlImpl) Recommend(from, to time.Time, page, size,
Where("sent_at >= ? AND sent_at <= ? AND pictures_num > 0", from.Unix(), to.Unix()).
Order("favor DESC").
Offset(offset).
Limit(size).Preload("Pics", "feedback = ?", 0).Find(&list).Error
Limit(size).Preload("Pics", "feedback in (?)", idl.DynamicFeedbackVec).Find(&list).Error
if err != nil {
return nil, err
}
Expand All @@ -147,7 +147,7 @@ func (impl *BilibiliPictureMysqlImpl) Random(rand float64) (list []*idl.Bilibili
return nil, err
}
offset := math.Floor((pair.MaxId - pair.MinId) * rand)
err = conn.Where("id >= ? AND feedback = 0", uint64(pair.MinId+offset)).
err = conn.Where("id >= ? AND feedback in (?)", uint64(pair.MinId+offset), idl.DynamicFeedbackVec).
Select("id,dynamic_id,img_src,img_attr,verify").
Preload("Dynamic").Limit(5).Find(&list).Error
if err != nil {
Expand All @@ -172,7 +172,7 @@ func (impl *BilibiliPictureMysqlImpl) Verify(req idl.BilibiliPictureVerifyReq, d
if conn.Error != nil {
return conn.Error
}
if conn.RowsAffected == 0 || req.FeedBack == 0 {
if conn.RowsAffected == 0 || req.FeedBack == idl.Default || req.FeedBack == idl.IncorrectTags || req.FeedBack == idl.OnPeriod {
return nil
}
return _tx.Table(idl.BilibiliDynamic{}.TableName()).
Expand Down

0 comments on commit bfdf3fe

Please sign in to comment.