MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / GetPricing

Function GetPricing

controller/pricing.go:11–47  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

9)
10
11func GetPricing(c *gin.Context) {
12 pricing := model.GetPricing()
13 userId, exists := c.Get("id")
14 usableGroup := map[string]string{}
15 groupRatio := map[string]float64{}
16 for s, f := range ratio_setting.GetGroupRatioCopy() {
17 groupRatio[s] = f
18 }
19 var group string
20 if exists {
21 user, err := model.GetUserCache(userId.(int))
22 if err == nil {
23 group = user.Group
24 for g := range groupRatio {
25 ratio, ok := ratio_setting.GetGroupGroupRatio(group, g)
26 if ok {
27 groupRatio[g] = ratio
28 }
29 }
30 }
31 }
32
33 usableGroup = setting.GetUserUsableGroups(group)
34 // check groupRatio contains usableGroup
35 for group := range ratio_setting.GetGroupRatioCopy() {
36 if _, ok := usableGroup[group]; !ok {
37 delete(groupRatio, group)
38 }
39 }
40
41 c.JSON(200, gin.H{
42 "success": true,
43 "data": pricing,
44 "group_ratio": groupRatio,
45 "usable_group": usableGroup,
46 })
47}
48
49func ResetModelRatio(c *gin.Context) {
50 defaultStr := ratio_setting.DefaultModelRatio2JSONString()

Callers

nothing calls this directly

Calls 6

GetPricingFunction · 0.92
GetGroupRatioCopyFunction · 0.92
GetUserCacheFunction · 0.92
GetGroupGroupRatioFunction · 0.92
GetUserUsableGroupsFunction · 0.92
GetMethod · 0.80

Tested by

no test coverage detected