mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 22:32:25 -05:00
[feature] Add instance-stats-randomize config option (#3718)
* [feature] Add `instance-stats-randomize` config option * don't use cache (overkill)
This commit is contained in:
parent
c47b9bd1d1
commit
a55bd6d2bd
13 changed files with 183 additions and 10 deletions
|
|
@ -21,7 +21,9 @@ import (
|
|||
"net/http"
|
||||
|
||||
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -58,6 +60,12 @@ func (m *Module) InstanceInformationGETHandlerV1(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if config.GetInstanceStatsRandomize() {
|
||||
// Replace actual stats with cached randomized ones.
|
||||
instance.Stats["user_count"] = util.Ptr(int(instance.RandomStats.TotalUsers))
|
||||
instance.Stats["status_count"] = util.Ptr(int(instance.RandomStats.Statuses))
|
||||
}
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, instance)
|
||||
}
|
||||
|
||||
|
|
@ -93,5 +101,10 @@ func (m *Module) InstanceInformationGETHandlerV2(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if config.GetInstanceStatsRandomize() {
|
||||
// Replace actual stats with cached randomized ones.
|
||||
instance.Usage.Users.ActiveMonth = int(instance.RandomStats.MonthlyActiveUsers)
|
||||
}
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, instance)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue