Skip to content

Commit b6accac

Browse files
committed
minor fixes to cloud filesystem charging based on testing
1 parent 05f0355 commit b6accac

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/packages/frontend/compute/purchases.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function ComputeServerStorageDescription({
7979
showProject
8080
/>
8181
. {period_end == null && <Cost service="compute-server-storage" inline />}{" "}
82-
<WhenKnown period_end={period_end} />
82+
{description.cost == null && <WhenKnown period_end={period_end} />}
8383
</div>
8484
);
8585
}

src/packages/server/compute/cloud-filesystem/create.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,16 @@ export async function createCloudFilesystem(opts: Options): Promise<number> {
271271
return id;
272272
}
273273

274-
export async function createCloudStoragePurchase({
275-
cloud_filesystem_id,
276-
account_id,
277-
project_id,
278-
bucket,
279-
period_start,
280-
}: {
274+
export async function createCloudStoragePurchase(opts: {
281275
cloud_filesystem_id: number;
282276
account_id: string;
283277
project_id: string;
284278
bucket: string;
285279
period_start?: Date;
286280
}) {
281+
const { cloud_filesystem_id, account_id, project_id, bucket, period_start } =
282+
opts;
283+
logger.debug("createCloudStoragePurchase: ", opts);
287284
const purchase_id = await createPurchase({
288285
client: null,
289286
account_id,

src/packages/server/compute/maintenance/purchases/manage-storage-purchases.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ async function computeBucketPurchaseCosts(bucketPurchases) {
120120
// a purchase created, then there would never be a purchase without
121121
// something like this (since new purchases get created normally only
122122
// on bucket creation and when running purchases are closed continued).
123-
async function ensureCloudFilesystemsHavePurchases() {
123+
export async function ensureCloudFilesystemsHavePurchases() {
124124
const pool = getPool();
125125
const { rows: missing } = await pool.query(
126126
"SELECT id, created, bucket, account_id, project_id FROM cloud_filesystems WHERE purchase_id IS NULL",
127127
);
128+
128129
for (const {
129130
id: cloud_filesystem_id,
130131
created,
@@ -173,8 +174,9 @@ async function getMostRecentPurchase(
173174
cloud_filesystem_id: number,
174175
): Promise<undefined | Purchase> {
175176
const pool = getPool();
177+
// this is not an efficient query... but we will probably never ever use this in practice so it does not matter.
176178
const { rows } = await pool.query(
177-
"SELECT * FROM purchases WHERE description.cloud_filesystem_id=$1 ORDER BY time DESC LIMIT 1",
179+
"SELECT * FROM purchases WHERE service = 'compute-server-storage' AND (description->'cloud_filesystem_id')::integer = $1 ORDER BY time DESC LIMIT 1",
178180
[cloud_filesystem_id],
179181
);
180182
return rows[0];

0 commit comments

Comments
 (0)