Commit 8bea1397 by creamlike1024

Merge branch 'wzxjohn-feature/wellknown'

parents 4f123cf9 9f165b89
...@@ -196,7 +196,7 @@ func DeleteHistoryLogs(c *gin.Context) { ...@@ -196,7 +196,7 @@ func DeleteHistoryLogs(c *gin.Context) {
}) })
return return
} }
count, err := model.DeleteOldLog(targetTimestamp) count, err := model.DeleteOldLog(c.Request.Context(), targetTimestamp, 100)
if err != nil { if err != nil {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"success": false, "success": false,
......
package model package model
import ( import (
"context"
"fmt" "fmt"
"one-api/common" "one-api/common"
"os" "os"
...@@ -340,7 +341,25 @@ func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelNa ...@@ -340,7 +341,25 @@ func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelNa
return token return token
} }
func DeleteOldLog(targetTimestamp int64) (int64, error) { func DeleteOldLog(ctx context.Context, targetTimestamp int64, limit int) (int64, error) {
result := LOG_DB.Where("created_at < ?", targetTimestamp).Delete(&Log{}) var total int64 = 0
return result.RowsAffected, result.Error
for {
if nil != ctx.Err() {
return total, ctx.Err()
}
result := LOG_DB.Where("created_at < ?", targetTimestamp).Limit(limit).Delete(&Log{})
if nil != result.Error {
return total, result.Error
}
total += result.RowsAffected
if result.RowsAffected < int64(limit) {
break
}
}
return total, nil
} }
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
verifyJSON, verifyJSON,
} from '../helpers/utils'; } from '../helpers/utils';
import { API } from '../helpers/api'; import { API } from '../helpers/api';
import axios from "axios";
const SystemSetting = () => { const SystemSetting = () => {
let [inputs, setInputs] = useState({ let [inputs, setInputs] = useState({
...@@ -374,7 +375,7 @@ const SystemSetting = () => { ...@@ -374,7 +375,7 @@ const SystemSetting = () => {
}; };
const submitOIDCSettings = async () => { const submitOIDCSettings = async () => {
if (inputs['oidc.well_known'] !== '') { if (inputs['oidc.well_known'] && inputs['oidc.well_known'] !== '') {
if ( if (
!inputs['oidc.well_known'].startsWith('http://') && !inputs['oidc.well_known'].startsWith('http://') &&
!inputs['oidc.well_known'].startsWith('https://') !inputs['oidc.well_known'].startsWith('https://')
...@@ -383,7 +384,7 @@ const SystemSetting = () => { ...@@ -383,7 +384,7 @@ const SystemSetting = () => {
return; return;
} }
try { try {
const res = await API.get(inputs['oidc.well_known']); const res = await axios.create().get(inputs['oidc.well_known']);
inputs['oidc.authorization_endpoint'] = inputs['oidc.authorization_endpoint'] =
res.data['authorization_endpoint']; res.data['authorization_endpoint'];
inputs['oidc.token_endpoint'] = res.data['token_endpoint']; inputs['oidc.token_endpoint'] = res.data['token_endpoint'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment