/
stats.go
47 lines (42 loc) · 1.71 KB
/
stats.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
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package params // import "github.com/juju/charmrepo/v6/csclient/params"
// Define the kinds to be included in stats keys.
const (
StatsArchiveDownload = "archive-download"
StatsArchiveDownloadPromulgated = "archive-download-promulgated"
StatsArchiveDelete = "archive-delete"
StatsArchiveFailedUpload = "archive-failed-upload"
StatsArchiveUpload = "archive-upload"
// The following kinds are in use in the legacy API.
StatsCharmInfo = "charm-info"
StatsCharmMissing = "charm-missing"
StatsCharmEvent = "charm-event"
)
// Statistic holds one element of a stats/counter response.
// See https://github.com/juju/charmstore/blob/v4/docs/API.md#get-statscounter
type Statistic struct {
Key string `json:",omitempty"`
Date string `json:",omitempty"`
Count int64
}
// StatsResponse holds the result of an id/meta/stats GET request.
// See https://github.com/juju/charmstore/blob/v4/docs/API.md#get-idmetastats
type StatsResponse struct {
// ArchiveDownloadCount is superceded by ArchiveDownload but maintained for
// backward compatibility.
ArchiveDownloadCount int64
// ArchiveDownload holds the downloads count for a specific revision of the
// entity.
ArchiveDownload StatsCount
// ArchiveDownloadAllRevisions holds the downloads count for all revisions
// of the entity.
ArchiveDownloadAllRevisions StatsCount
}
// StatsCount holds stats counts and is used as part of StatsResponse.
type StatsCount struct {
Total int64 // Total count over all time.
Day int64 // Count over the last day.
Week int64 // Count over the last week.
Month int64 // Count over the last month.
}