feat(api): support optional systemInfo in submissions
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m17s
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m17s
Extend the submission contract to accept a `systemInfo` object and persist it with each submission, including deep-copy support for `extra` metadata. Also update client-facing docs and HTTP examples (JSON and multipart) and document that the schema is available at `GET /api/schema`, so clients can reliably implement the updated payload format.feat(api): support optional systemInfo in submissions Extend the submission contract to accept a `systemInfo` object and persist it with each submission, including deep-copy support for `extra` metadata. Also update client-facing docs and HTTP examples (JSON and multipart) and document that the schema is available at `GET /api/schema`, so clients can reliably implement the updated payload format.
This commit is contained in:
@@ -39,6 +39,30 @@ type CPUCoreDescriptor struct {
|
||||
Type int `json:"Type"`
|
||||
}
|
||||
|
||||
type SystemInfo struct {
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
OSName string `json:"osName,omitempty"`
|
||||
OSVersion string `json:"osVersion,omitempty"`
|
||||
Distro string `json:"distro,omitempty"`
|
||||
KernelVersion string `json:"kernelVersion,omitempty"`
|
||||
KernelArch string `json:"kernelArch,omitempty"`
|
||||
Architecture string `json:"architecture,omitempty"`
|
||||
Locale string `json:"locale,omitempty"`
|
||||
Timezone string `json:"timezone,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
ISP string `json:"isp,omitempty"`
|
||||
SessionID string `json:"sessionID,omitempty"`
|
||||
UserID string `json:"userID,omitempty"`
|
||||
ClientVersion string `json:"clientVersion,omitempty"`
|
||||
AppVersion string `json:"appVersion,omitempty"`
|
||||
IPAddress string `json:"ipAddress,omitempty"`
|
||||
ForwardedFor string `json:"forwardedFor,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
Extra map[string]any `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
type CoreResult struct {
|
||||
LogicalID int `json:"logicalID"`
|
||||
CoreType string `json:"coreType"`
|
||||
@@ -58,10 +82,11 @@ type BenchmarkResult struct {
|
||||
}
|
||||
|
||||
type Submission struct {
|
||||
SubmissionID string `json:"submissionID"`
|
||||
Submitter string `json:"submitter"`
|
||||
Platform string `json:"platform"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
SubmissionID string `json:"submissionID"`
|
||||
Submitter string `json:"submitter"`
|
||||
Platform string `json:"platform"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
SystemInfo *SystemInfo `json:"systemInfo,omitempty"`
|
||||
BenchmarkResult
|
||||
}
|
||||
|
||||
@@ -158,6 +183,16 @@ func CloneSubmission(submission *Submission) *Submission {
|
||||
if len(submission.CPUInfo.SupportedFeatures) > 0 {
|
||||
copySubmission.CPUInfo.SupportedFeatures = append([]string(nil), submission.CPUInfo.SupportedFeatures...)
|
||||
}
|
||||
if submission.SystemInfo != nil {
|
||||
copySystemInfo := *submission.SystemInfo
|
||||
if len(submission.SystemInfo.Extra) > 0 {
|
||||
copySystemInfo.Extra = make(map[string]any, len(submission.SystemInfo.Extra))
|
||||
for key, value := range submission.SystemInfo.Extra {
|
||||
copySystemInfo.Extra[key] = value
|
||||
}
|
||||
}
|
||||
copySubmission.SystemInfo = ©SystemInfo
|
||||
}
|
||||
|
||||
return ©Submission
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user