-
Notifications
You must be signed in to change notification settings - Fork 775
Expand file tree
/
Copy pathenterprise_ai_credit_usage.go
More file actions
56 lines (46 loc) · 2.85 KB
/
Copy pathenterprise_ai_credit_usage.go
File metadata and controls
56 lines (46 loc) · 2.85 KB
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
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package models
import (
"github.com/apache/incubator-devlake/core/models/common"
)
// GhCopilotEnterpriseAiCreditUsage tracks AI credit consumption at the enterprise level.
// One row per time period per model per entity (user, org, or cost center).
type GhCopilotEnterpriseAiCreditUsage struct {
ConnectionId uint64 `gorm:"primaryKey" json:"connectionId"`
ScopeId string `gorm:"primaryKey;type:varchar(255)" json:"scopeId"`
Year int `gorm:"primaryKey" json:"year"`
Month int `gorm:"primaryKey" json:"month"`
Day int `gorm:"primaryKey" json:"day"`
Enterprise string `gorm:"primaryKey;type:varchar(255)" json:"enterprise" gorm:"comment:Enterprise slug"`
Model string `gorm:"primaryKey;type:varchar(255)" json:"model" gorm:"comment:AI model name (e.g., gpt-4.1)"`
Organization string `gorm:"index;type:varchar(255)" json:"organization" gorm:"comment:Organization within enterprise, if specified"`
User string `gorm:"index;type:varchar(255)" json:"user" gorm:"comment:Username, if specified"`
Product string `gorm:"type:varchar(32)" json:"product" gorm:"comment:Product name (e.g., copilot)"`
CostCenterId string `gorm:"index;type:varchar(255)" json:"costCenterId" gorm:"comment:Cost center identifier"`
CostCenterName string `gorm:"type:varchar(255)" json:"costCenterName" gorm:"comment:Cost center display name"`
// Credit usage breakdown
GrossQuantity float64 `json:"grossQuantity" gorm:"comment:Raw credits consumed"`
DiscountQuantity float64 `json:"discountQuantity" gorm:"comment:Credits discounted"`
NetQuantity float64 `json:"netQuantity" gorm:"comment:Credits after discount"`
PricePerUnit float64 `json:"pricePerUnit" gorm:"comment:Price per credit unit"`
GrossAmount float64 `json:"grossAmount" gorm:"comment:Gross cost before discount"`
DiscountAmount float64 `json:"discountAmount" gorm:"comment:Discount amount"`
NetAmount float64 `json:"netAmount" gorm:"comment:Net cost after discount"`
common.NoPKModel
}
func (GhCopilotEnterpriseAiCreditUsage) TableName() string {
return "_tool_copilot_enterprise_ai_credit_usage"
}