✨ Better check in experience random algorithm
This commit is contained in:
parent
55b3a6f164
commit
312cf820ab
9
.idea/workspace.xml
generated
9
.idea/workspace.xml
generated
@ -4,9 +4,10 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Result modifiers in check-in">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":boom: Passing relationship api arguments in body instead of querystring">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/relationships_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/relationships_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/check_in_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/check_in_api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/check_in.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/check_in.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -159,7 +160,6 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||||
<MESSAGE value=":sparkles: Support users related rpc calls" />
|
|
||||||
<MESSAGE value=":technologist: Improve DX by extending authkit" />
|
<MESSAGE value=":technologist: Improve DX by extending authkit" />
|
||||||
<MESSAGE value=":sparkles: Add list relative method into authkit" />
|
<MESSAGE value=":sparkles: Add list relative method into authkit" />
|
||||||
<MESSAGE value=":sparkles: Realm operations now available in authkit" />
|
<MESSAGE value=":sparkles: Realm operations now available in authkit" />
|
||||||
@ -184,7 +184,8 @@
|
|||||||
<MESSAGE value=":mute: Remove authenticate result logging" />
|
<MESSAGE value=":mute: Remove authenticate result logging" />
|
||||||
<MESSAGE value=":truck: Rename daily-sign to check-in" />
|
<MESSAGE value=":truck: Rename daily-sign to check-in" />
|
||||||
<MESSAGE value=":sparkles: Result modifiers in check-in" />
|
<MESSAGE value=":sparkles: Result modifiers in check-in" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Result modifiers in check-in" />
|
<MESSAGE value=":boom: Passing relationship api arguments in body instead of querystring" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":boom: Passing relationship api arguments in body instead of querystring" />
|
||||||
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
|
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
|
@ -99,7 +99,7 @@ func doCheckIn(c *fiber.Ctx) error {
|
|||||||
if record, err := services.CheckIn(user); err != nil {
|
if record, err := services.CheckIn(user); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
} else {
|
} else {
|
||||||
services.AddEvent(user.ID, "dailySign", strconv.Itoa(int(record.ID)), c.IP(), c.Get(fiber.HeaderUserAgent))
|
services.AddEvent(user.ID, "checkIn", strconv.Itoa(int(record.ID)), c.IP(), c.Get(fiber.HeaderUserAgent))
|
||||||
return c.JSON(record)
|
return c.JSON(record)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
||||||
"git.solsynth.dev/hypernet/passport/pkg/internal/database"
|
"git.solsynth.dev/hypernet/passport/pkg/internal/database"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"math"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -38,9 +37,11 @@ const CheckInResultModifiersLength = 4
|
|||||||
|
|
||||||
func CheckIn(user models.Account) (models.CheckInRecord, error) {
|
func CheckIn(user models.Account) (models.CheckInRecord, error) {
|
||||||
tier := rand.Intn(5)
|
tier := rand.Intn(5)
|
||||||
|
expMax := 100 * (tier + 1)
|
||||||
|
expMin := 100
|
||||||
record := models.CheckInRecord{
|
record := models.CheckInRecord{
|
||||||
ResultTier: tier,
|
ResultTier: tier,
|
||||||
ResultExperience: rand.Intn(int(math.Max(float64(tier), 1)*100)+1-100) + 100,
|
ResultExperience: rand.Intn(expMax-expMin) + expMin,
|
||||||
AccountID: user.ID,
|
AccountID: user.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user