Skip to content

Commit

Permalink
Make uniqueness key uuid, use max referrals in fe
Browse files Browse the repository at this point in the history
  • Loading branch information
MauAraujo committed May 1, 2024
1 parent 08bc75a commit 7b0fbe2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
19 changes: 3 additions & 16 deletions dashboard/src/main/home/project-settings/BillingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ function BillingPage(): JSX.Element {

const { usage } = useCustomerUsage("day", true);

const trialEnding = (starting_on: string, ending_before: string): string => {
if (ending_before === undefined) {
return "";
}

const diff = dayjs(ending_before).diff(dayjs());
if (diff <= 0) {
return `Started on ${readableDate(starting_on)}`;
}

return `Free trial ends ${dayjs().to(dayjs(ending_before))}`;
};

const processedData = useMemo(() => {
const before = usage;
const resultMap = new Map();
Expand Down Expand Up @@ -270,8 +257,8 @@ function BillingPage(): JSX.Element {
</Text>
<Spacer y={1} />
{usage?.length &&
usage.length > 0 &&
usage[0].usage_metrics.length > 0 ? (
usage.length > 0 &&
usage[0].usage_metrics.length > 0 ? (
<Flex>
<BarWrapper>
<Bars
Expand Down Expand Up @@ -343,7 +330,7 @@ function BillingPage(): JSX.Element {
<Spacer y={1} />
<Text color="helper">
You have referred{" "}
{referralDetails ? referralDetails.referral_count : "?"}/10 users.
{referralDetails ? referralDetails.referral_count : "?"}/{referralDetails?.max_allowed_referrals} users.
</Text>
</Modal>
)}
Expand Down
13 changes: 7 additions & 6 deletions dashboard/src/shared/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ export type FormElement = {
export type RepoType = {
FullName: string;
} & (
| {
| {
Kind: "github";
GHRepoID: number;
}
| {
| {
Kind: "gitlab";
GitIntegrationId: number;
}
);
);

export type FileType = {
path: string;
Expand Down Expand Up @@ -344,6 +344,7 @@ export type ProjectType = {
user_id: number;
project_id: number;
}>;
referral_code: string;
};

export type ChoiceType = {
Expand Down Expand Up @@ -379,15 +380,15 @@ export type ActionConfigType = {
image_repo_uri: string;
dockerfile_path?: string;
} & (
| {
| {
kind: "gitlab";
gitlab_integration_id: number;
}
| {
| {
kind: "github";
git_repo_id: number;
}
);
);

export type GithubActionConfigType = ActionConfigType & {
kind: "github";
Expand Down
5 changes: 1 addition & 4 deletions internal/billing/metronome.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,9 @@ func (m MetronomeClient) CreateCreditsGrant(ctx context.Context, customerID uuid
return telemetry.Error(ctx, span, err, "failed to get credit type id")
}

// Uniqueness key is used to prevent duplicate grants
uniquenessKey := fmt.Sprintf("%s-referral-reward", customerID)

req := types.CreateCreditsGrantRequest{
CustomerID: customerID,
UniquenessKey: uniquenessKey,
UniquenessKey: uuid.NewString(),
GrantAmount: types.GrantAmountID{
Amount: grantAmount,
CreditTypeID: creditTypeID,
Expand Down

0 comments on commit 7b0fbe2

Please sign in to comment.