refactor(up/down limit): allow floating value & default to 1

This commit is contained in:
Nicolas Meienberger 2026-01-15 18:27:50 +01:00
parent 31719103f6
commit f4a222aa15
5 changed files with 14 additions and 14 deletions

View file

@ -61,12 +61,12 @@ export const AdvancedForm = ({ form }: Props) => {
disabled={!uploadLimitEnabled}
type="number"
min={1}
step={1}
step={0.1}
max={999999}
placeholder="10"
className="pr-12"
{...field}
onChange={(e) => field.onChange(parseInt(e.target.value, 10) || 1)}
onChange={(e) => field.onChange(parseFloat(e.target.value) || 1)}
/>
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
<div className="h-4 w-px bg-border" />
@ -139,12 +139,12 @@ export const AdvancedForm = ({ form }: Props) => {
placeholder="10"
type="number"
min={1}
step={1}
step={0.1}
max={999999}
disabled={!downloadLimitEnabled}
className="pr-12"
{...field}
onChange={(e) => field.onChange(parseInt(e.target.value, 10) || 1)}
onChange={(e) => field.onChange(parseFloat(e.target.value) || 1)}
/>
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
<div className="h-4 w-px bg-border" />

View file

@ -1,6 +1,6 @@
ALTER TABLE `repositories_table` ADD `upload_limit_enabled` integer DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `upload_limit_value` real DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `upload_limit_value` real DEFAULT 1 NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `upload_limit_unit` text DEFAULT 'Mbps' NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `download_limit_enabled` integer DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `download_limit_value` real DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `download_limit_unit` text DEFAULT 'Mbps' NOT NULL;
ALTER TABLE `repositories_table` ADD `download_limit_value` real DEFAULT 1 NOT NULL;--> statement-breakpoint
ALTER TABLE `repositories_table` ADD `download_limit_unit` text DEFAULT 'Mbps' NOT NULL;

View file

@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "9506e3c1-3131-4621-b74b-6023d63a0f00",
"id": "73952303-c589-4b3b-93f1-b70478329dbf",
"prevId": "ad86ee2a-231e-45d1-9910-e4b7cac6a8af",
"tables": {
"account": {
@ -717,7 +717,7 @@
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 0
"default": 1
},
"upload_limit_unit": {
"name": "upload_limit_unit",
@ -741,7 +741,7 @@
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 0
"default": 1
},
"download_limit_unit": {
"name": "download_limit_unit",

View file

@ -236,8 +236,8 @@
{
"idx": 33,
"version": "6",
"when": 1768497229303,
"tag": "0033_thankful_master_chief",
"when": 1768497767122,
"tag": "0033_chunky_tyrannus",
"breakpoints": true
}
]

View file

@ -166,10 +166,10 @@ export const repositoriesTable = sqliteTable("repositories_table", {
lastChecked: int("last_checked", { mode: "number" }),
lastError: text("last_error"),
uploadLimitEnabled: int("upload_limit_enabled", { mode: "boolean" }).notNull().default(false),
uploadLimitValue: real("upload_limit_value").notNull().default(0),
uploadLimitValue: real("upload_limit_value").notNull().default(1),
uploadLimitUnit: text("upload_limit_unit").$type<BandwidthUnit>().notNull().default("Mbps"),
downloadLimitEnabled: int("download_limit_enabled", { mode: "boolean" }).notNull().default(false),
downloadLimitValue: real("download_limit_value").notNull().default(0),
downloadLimitValue: real("download_limit_value").notNull().default(1),
downloadLimitUnit: text("download_limit_unit").$type<BandwidthUnit>().notNull().default("Mbps"),
createdAt: int("created_at", { mode: "number" })
.notNull()