/
rollup.go
67 lines (59 loc) 路 3.45 KB
/
rollup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package responses
import (
"time"
"github.com/celenium-io/celestia-indexer/internal/storage"
)
type RollupWithStats struct {
Id uint64 `example:"321" format:"integer" json:"id" swaggertype:"integer"`
Name string `example:"Rollup name" format:"string" json:"name" swaggertype:"string"`
Description string `example:"Long rollup description" format:"string" json:"description,omitempty" swaggertype:"string"`
Website string `example:"https://website.com" format:"string" json:"website,omitempty" swaggertype:"string"`
Twitter string `example:"https://x.com/account" format:"string" json:"twitter,omitempty" swaggertype:"string"`
Github string `example:"https://github.com/account" format:"string" json:"github,omitempty" swaggertype:"string"`
Logo string `example:"https://some_link.com/image.png" format:"string" json:"logo,omitempty" swaggertype:"string"`
Slug string `example:"rollup_slug" format:"string" json:"slug" swaggertype:"string"`
BlobsCount int64 `example:"2" format:"integer" json:"blobs_count" swaggertype:"integer"`
Size int64 `example:"1000" format:"integer" json:"size" swaggertype:"integer"`
LastAction time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"last_message_time" swaggertype:"string"`
FirstAction time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"first_message_time" swaggertype:"string"`
}
func NewRollupWithStats(r storage.RollupWithStats) RollupWithStats {
return RollupWithStats{
Id: r.Id,
Name: r.Name,
Description: r.Description,
Github: r.GitHub,
Twitter: r.Twitter,
Website: r.Website,
Logo: r.Logo,
Slug: r.Slug,
BlobsCount: r.BlobsCount,
Size: r.Size,
LastAction: r.LastActionTime,
FirstAction: r.FirstActionTime,
}
}
type Rollup struct {
Id uint64 `example:"321" format:"integer" json:"id" swaggertype:"integer"`
Name string `example:"Rollup name" format:"string" json:"name" swaggertype:"string"`
Description string `example:"Long rollup description" format:"string" json:"description,omitempty" swaggertype:"string"`
Website string `example:"https://website.com" format:"string" json:"website,omitempty" swaggertype:"string"`
Twitter string `example:"https://x.com/account" format:"string" json:"twitter,omitempty" swaggertype:"string"`
Github string `example:"https://github.com/account" format:"string" json:"github,omitempty" swaggertype:"string"`
Logo string `example:"https://some_link.com/image.png" format:"string" json:"logo,omitempty" swaggertype:"string"`
Slug string `example:"rollup_slug" format:"string" json:"slug" swaggertype:"string"`
}
func NewRollup(r *storage.Rollup) Rollup {
return Rollup{
Id: r.Id,
Name: r.Name,
Description: r.Description,
Github: r.GitHub,
Twitter: r.Twitter,
Website: r.Website,
Logo: r.Logo,
Slug: r.Slug,
}
}