feature: #543 Rate limits are now per action-entity instead of per action
This commit is contained in:
parent
88f639d29f
commit
ba29325c15
|
|
@ -87,6 +87,7 @@ type InternalLogEntry struct {
|
||||||
Process *os.Process
|
Process *os.Process
|
||||||
Username string
|
Username string
|
||||||
Index int64
|
Index int64
|
||||||
|
EntityPrefix string
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The following 3 properties are obviously on Action normally, but it's useful
|
The following 3 properties are obviously on Action normally, but it's useful
|
||||||
|
|
@ -249,6 +250,7 @@ func (e *Executor) ExecRequest(req *ExecutionRequest) (*sync.WaitGroup, string)
|
||||||
ActionTitle: "notfound",
|
ActionTitle: "notfound",
|
||||||
ActionIcon: "💩",
|
ActionIcon: "💩",
|
||||||
Username: req.AuthenticatedUser.Username,
|
Username: req.AuthenticatedUser.Username,
|
||||||
|
EntityPrefix: req.EntityPrefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, isDuplicate := e.GetLog(req.TrackingID)
|
_, isDuplicate := e.GetLog(req.TrackingID)
|
||||||
|
|
@ -341,6 +343,10 @@ func getExecutionsCount(rate config.RateSpec, req *ExecutionRequest) int {
|
||||||
then := time.Now().Add(-duration)
|
then := time.Now().Add(-duration)
|
||||||
|
|
||||||
for _, logEntry := range req.executor.GetLogsByActionId(req.Action.ID) {
|
for _, logEntry := range req.executor.GetLogsByActionId(req.Action.ID) {
|
||||||
|
if logEntry.EntityPrefix != req.EntityPrefix {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if logEntry.DatetimeStarted.After(then) && !logEntry.Blocked {
|
if logEntry.DatetimeStarted.After(then) && !logEntry.Blocked {
|
||||||
|
|
||||||
executions += 1
|
executions += 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue