Skip to content

Commit

Permalink
RSDK-9176: add dataset wrappers (#4583)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplenicole730 authored Nov 26, 2024
1 parent 3225263 commit 4f6620c
Show file tree
Hide file tree
Showing 7 changed files with 624 additions and 353 deletions.
3 changes: 1 addition & 2 deletions app/app_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var (
pbOrganization = pb.Organization{
Id: organization.ID,
Name: organization.Name,
CreatedOn: timestamppb.New(*organization.CreatedOn),
CreatedOn: pbCreatedOn,
PublicNamespace: organization.PublicNamespace,
DefaultRegion: organization.DefaultRegion,
Cid: organization.Cid,
Expand All @@ -108,7 +108,6 @@ var (
OrgName: name,
}
lastLogin = time.Now().UTC().Round(time.Millisecond)
createdOn = time.Now().UTC().Round(time.Millisecond)
authorization = Authorization{
AuthorizationType: authorizationType,
AuthorizationID: authorizationID,
Expand Down
37 changes: 27 additions & 10 deletions app/billing_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,22 @@ type GetCurrentMonthUsageResponse struct {
}

func getCurrentMonthUsageResponseFromProto(response *pb.GetCurrentMonthUsageResponse) *GetCurrentMonthUsageResponse {
startDate := response.StartDate.AsTime()
endDate := response.EndDate.AsTime()
var startDate, endDate *time.Time
if response.StartDate != nil {
d := response.StartDate.AsTime()
startDate = &d
}
if response.EndDate != nil {
d := response.EndDate.AsTime()
endDate = &d
}
var costs []*ResourceUsageCostsBySource
for _, cost := range response.ResourceUsageCostsBySource {
costs = append(costs, resourceUsageCostsBySourceFromProto(cost))
}
return &GetCurrentMonthUsageResponse{
StartDate: &startDate,
EndDate: &endDate,
StartDate: startDate,
EndDate: endDate,
ResourceUsageCostsBySource: costs,
Subtotal: response.Subtotal,
}
Expand Down Expand Up @@ -220,16 +227,26 @@ type InvoiceSummary struct {
}

func invoiceSummaryFromProto(summary *pb.InvoiceSummary) *InvoiceSummary {
invoiceDate := summary.InvoiceDate.AsTime()
dueDate := summary.DueDate.AsTime()
paidDate := summary.PaidDate.AsTime()
var invoiceDate, dueDate, paidDate *time.Time
if summary.InvoiceDate != nil {
d := summary.InvoiceDate.AsTime()
invoiceDate = &d
}
if summary.DueDate != nil {
d := summary.DueDate.AsTime()
dueDate = &d
}
if summary.PaidDate != nil {
d := summary.PaidDate.AsTime()
paidDate = &d
}
return &InvoiceSummary{
ID: summary.Id,
InvoiceDate: &invoiceDate,
InvoiceDate: invoiceDate,
InvoiceAmount: summary.InvoiceAmount,
Status: summary.Status,
DueDate: &dueDate,
PaidDate: &paidDate,
DueDate: dueDate,
PaidDate: paidDate,
}
}

Expand Down
8 changes: 7 additions & 1 deletion app/common.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package app

import "time"
import (
"time"

"google.golang.org/protobuf/types/known/timestamppb"
)

// Constants used throughout app.
const (
Expand All @@ -23,4 +27,6 @@ var (
tags = []string{tag}
limit = 2
pbLimit = uint64(limit)
createdOn = time.Now().UTC().Round(time.Millisecond)
pbCreatedOn = timestamppb.New(createdOn)
)
Loading

0 comments on commit 4f6620c

Please sign in to comment.