Skip to content

Commit ed0b03f

Browse files
authored
Add rentableOrRentedBy query in dedicated filter (#3740)
* Add rentableOrRentedBy query in dedicated filter * rm unwanted filters * revert unrelated code * Get available for filter back * Handle not rented node error * Fix check nodes condition * upgrade lerna version * discard useless github workflows changes * Update nodeSelector.ts * Fix filter options * disable auto selection for dedicated nodes
1 parent bcb724a commit ed0b03f

File tree

6 files changed

+10
-2
lines changed

6 files changed

+10
-2
lines changed

packages/grid_client/src/modules/models.ts

+1
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ class FilterOptions {
639639
@Expose() @IsOptional() @Transform(({ value }) => NodeStatus[value]) @IsEnum(NodeStatus) status?: NodeStatus;
640640
@Expose() @IsOptional() @IsString() region?: string;
641641
@Expose() @IsOptional() @IsBoolean() healthy?: boolean;
642+
@Expose() @IsOptional() @IsInt() rentableOrRentedBy?: number;
642643
@Expose() @IsOptional() @IsBoolean() planetary?: boolean;
643644
@Expose() @IsOptional() @IsBoolean() mycelium?: boolean;
644645
@Expose() @IsOptional() @IsBoolean() wireguard?: boolean;

packages/grid_client/src/primitives/nodes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ class Nodes {
460460
healthy: options.healthy,
461461
sort_by: SortBy.FreeCRU,
462462
sort_order: SortOrder.Desc,
463+
rentable_or_rented_by: options.rentableOrRentedBy,
463464
features: options.features,
464465
};
465466

packages/playground/src/components/node_selector/TfAutoNodeSelector.vue

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export default {
230230
);
231231
232232
if (node) {
233+
if (node?.dedicated && node.rentContractId === 0) return false;
233234
await props.loadFarm(node.farmId);
234235
bindModelValue(node);
235236
nodeInputValidateTask.value.run(node);

packages/playground/src/components/node_selector/TfNodeDetailsCard.vue

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
if (status === 'Init' && node) {
1919
$emit('node:select', (node as NodeInfo));
2020
}
21+
if(node?.dedicated && node.rentContractId === 0) return false
2122
await validateRentContract(gridStore, node as NodeInfo);
2223
}
2324
: undefined,

packages/playground/src/types/nodeSelector.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface SelectionDetailsFilters {
2323
certified?: boolean;
2424
dedicated?: boolean;
2525
exclusiveFor?: string;
26+
rentable_or_rented_by?: number;
2627
planetary?: boolean;
2728
mycelium?: boolean;
2829
wireguard?: boolean;

packages/playground/src/utils/nodeSelector.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ export function normalizeNodeFilters(
201201
publicIPs: filters.ipv4 || undefined,
202202
hasIPv6: filters.ipv6 || undefined,
203203
hasGPU: filters.hasGPU || undefined,
204-
rentedBy: filters.dedicated ? options?.twinId : undefined,
205204
certified: filters.certified || undefined,
206-
availableFor: options?.twinId,
205+
availableFor: filters.dedicated ? undefined : options?.twinId,
207206
region: options?.location.region ? options?.location.region : options?.location.subregion,
208207
country: options?.location.country,
209208
gateway: options?.gateway,
210209
healthy: true,
210+
rentableOrRentedBy: filters.dedicated ? options?.twinId : undefined,
211211
planetary: filters.planetary,
212212
mycelium: filters.mycelium,
213213
wireguard: filters.wireguard,
@@ -227,6 +227,9 @@ export async function validateRentContract(
227227
}
228228

229229
try {
230+
if (node.dedicated && node.rentedByTwinId === 0) {
231+
throw `Node ${node.nodeId} is not rented`;
232+
}
230233
if (node.rentContractId !== 0) {
231234
const contractInfo = await gridStore.grid.contracts.get({
232235
id: node.rentContractId,

0 commit comments

Comments
 (0)