Skip to content

Commit

Permalink
Merge pull request #666 from Path-of-Modifiers/663-fix-cannot-cast-nu…
Browse files Browse the repository at this point in the history
…ll-text-value-in-jsonb-to-boolean-error

#663 Removed unused plot inputs and fixed autofocus min max
  • Loading branch information
bogadisa authored Nov 16, 2024
2 parents 37f3ba6 + 4853745 commit 2623e54
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 163 deletions.
1 change: 0 additions & 1 deletion src/backend_api/app/core/schemas/plot/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ItemSpecs(_pydantic.BaseModel):
influences: Influences | None = None
searing: bool | None = None
tangled: bool | None = None
isRelic: bool | None = None
foilVariation: int | None = None


Expand Down
18 changes: 11 additions & 7 deletions src/backend_api/app/plotting/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pydantic import TypeAdapter
from sqlalchemy import (
BinaryExpression,
Boolean,
ColumnElement,
Result,
and_,
Expand Down Expand Up @@ -242,12 +241,17 @@ def _apply_item_specs(
item_spec_query_fields.pop("maxIlvl")

if item_spec_query.influences is not None:
item_specifications += [
model_Item.influences[key].cast(Boolean)
== item_spec_query.influences.__dict__[key]
for key in item_spec_query.influences.model_fields
if (item_spec_query.influences.__dict__[key] is not None)
]
# item_specifications += [
# (
# model_Item.influences[key].isnot(None).cast(Boolean)
# if model_Item.influences[key].is_not(None)
# else model_Item.influences[key]
# == item_spec_query.influences.__dict__[key]
# )
# for key in item_spec_query.influences.model_fields
# if item_spec_query.influences.__dict__[key] is not None
# ]
# TODO: Fix influences query and uncomment above
item_spec_query_fields.pop("influences")

item_specifications += [
Expand Down
1 change: 0 additions & 1 deletion src/backend_api/app/tests/utils/model_utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async def create_minimal_random_plot_query_dict(db: Session) -> dict[str, Any]:
"influences": None,
"searing": None,
"tangled": None,
"isRelic": None,
"foilVariation": None,
}

Expand Down
45 changes: 1 addition & 44 deletions src/frontend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3145,10 +3145,6 @@
"type": "integer",
"title": "Itembasetypeid"
},
"typeLine": {
"type": "string",
"title": "Typeline"
},
"ilvl": {
"type": "integer",
"title": "Ilvl"
Expand Down Expand Up @@ -3271,17 +3267,6 @@
],
"title": "Tangled"
},
"isRelic": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Isrelic"
},
"prefixes": {
"anyOf": [
{
Expand Down Expand Up @@ -3328,7 +3313,6 @@
"required": [
"league",
"itemBaseTypeId",
"typeLine",
"ilvl",
"rarity",
"createdHoursSinceLaunch",
Expand Down Expand Up @@ -3482,10 +3466,6 @@
"type": "integer",
"title": "Itembasetypeid"
},
"typeLine": {
"type": "string",
"title": "Typeline"
},
"ilvl": {
"type": "integer",
"title": "Ilvl"
Expand Down Expand Up @@ -3608,17 +3588,6 @@
],
"title": "Tangled"
},
"isRelic": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Isrelic"
},
"prefixes": {
"anyOf": [
{
Expand Down Expand Up @@ -3661,7 +3630,6 @@
"required": [
"league",
"itemBaseTypeId",
"typeLine",
"ilvl",
"rarity",
"createdHoursSinceLaunch"
Expand Down Expand Up @@ -3880,17 +3848,6 @@
],
"title": "Tangled"
},
"isRelic": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Isrelic"
},
"foilVariation": {
"anyOf": [
{
Expand Down Expand Up @@ -5242,4 +5199,4 @@
}
}
}
}
}
2 changes: 0 additions & 2 deletions src/frontend/src/client/models/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type Item = {
name?: (string | null);
league: string;
itemBaseTypeId: number;
typeLine: string;
ilvl: number;
rarity: string;
identified?: boolean;
Expand All @@ -21,7 +20,6 @@ export type Item = {
influences?: (Influences | null);
searing?: (boolean | null);
tangled?: (boolean | null);
isRelic?: (boolean | null);
prefixes?: (number | null);
suffixes?: (number | null);
foilVariation?: (number | null);
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/src/client/models/ItemCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type ItemCreate = {
name?: (string | null);
league: string;
itemBaseTypeId: number;
typeLine: string;
ilvl: number;
rarity: string;
identified?: boolean;
Expand All @@ -21,7 +20,6 @@ export type ItemCreate = {
influences?: (Influences | null);
searing?: (boolean | null);
tangled?: (boolean | null);
isRelic?: (boolean | null);
prefixes?: (number | null);
suffixes?: (number | null);
foilVariation?: (number | null);
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/client/models/ItemSpecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type ItemSpecs = {
influences?: (Influences | null);
searing?: (boolean | null);
tangled?: (boolean | null);
isRelic?: (boolean | null);
foilVariation?: (number | null);
};

12 changes: 0 additions & 12 deletions src/frontend/src/client/schemas/$Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export const $Item = {
type: 'number',
isRequired: true,
},
typeLine: {
type: 'string',
isRequired: true,
},
ilvl: {
type: 'number',
isRequired: true,
Expand Down Expand Up @@ -115,14 +111,6 @@ export const $Item = {
type: 'null',
}],
},
isRelic: {
type: 'any-of',
contains: [{
type: 'boolean',
}, {
type: 'null',
}],
},
prefixes: {
type: 'any-of',
contains: [{
Expand Down
12 changes: 0 additions & 12 deletions src/frontend/src/client/schemas/$ItemCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export const $ItemCreate = {
type: 'number',
isRequired: true,
},
typeLine: {
type: 'string',
isRequired: true,
},
ilvl: {
type: 'number',
isRequired: true,
Expand Down Expand Up @@ -115,14 +111,6 @@ export const $ItemCreate = {
type: 'null',
}],
},
isRelic: {
type: 'any-of',
contains: [{
type: 'boolean',
}, {
type: 'null',
}],
},
prefixes: {
type: 'any-of',
contains: [{
Expand Down
8 changes: 0 additions & 8 deletions src/frontend/src/client/schemas/$ItemSpecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ export const $ItemSpecs = {
type: 'null',
}],
},
isRelic: {
type: 'any-of',
contains: [{
type: 'boolean',
}, {
type: 'null',
}],
},
foilVariation: {
type: 'any-of',
contains: [{
Expand Down
10 changes: 2 additions & 8 deletions src/frontend/src/components/Input/ItemInputComp/IsItemInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ interface IsItemInputProps {
| "hunter"
| "warlord"
| "searing"
| "tangled"
| "isRelic";
| "tangled";
text: string;
}

Expand All @@ -45,7 +44,6 @@ export const IsItemInput = ({ itemSpecKey, text }: IsItemInputProps) => {
setItemSpecWarlordInfluence,
setItemSpecSearing,
setItemSpecTangled,
setItemSpecIsRelic,
} = useGraphInputStore();

let presetValue: boolean | undefined | null;
Expand Down Expand Up @@ -107,10 +105,6 @@ export const IsItemInput = ({ itemSpecKey, text }: IsItemInputProps) => {
presetValue = itemSpec?.tangled;
setItemSpecMisc = setItemSpecTangled;
break;
case "isRelic":
presetValue = itemSpec?.isRelic;
setItemSpecMisc = setItemSpecIsRelic;
break;
default:
throw "Couldn't match 'itemSpecKey' with item spec set function.";
}
Expand All @@ -129,7 +123,7 @@ export const IsItemInput = ({ itemSpecKey, text }: IsItemInputProps) => {
];

const defaultOption = optionsList.find(
(option) => convertToBoolean(option.value) === presetValue
(option) => convertToBoolean(option.value) === presetValue,
);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
import { useGraphInputStore } from "../../../store/GraphInputStore";
import {
MinMaxNumberInput,
HandleNumberChangeEventFunction,
DefaultMinMaxValues,
MinMaxNumberInput,
HandleNumberChangeEventFunction,
DefaultMinMaxValues,
} from "../StandardLayoutInput/MinMaxNumberInput";

interface MinMaxInputProps {
text: string;
text: string;
}

// Min Max Item Lvl Input Component - This component is used to input the min and max ilvl of an item.
export const MinMaxIlvlInput = (props: MinMaxInputProps) => {
const { itemSpec, setItemSpecMinIlvl, setItemSpecMaxIlvl } =
useGraphInputStore();

const handleMinChange = (eventValue: string) => {
const eventValueInt = parseInt(eventValue);

setItemSpecMinIlvl(eventValueInt);
};

const handleMaxChange = (eventValue: string) => {
const eventValueInt = parseInt(eventValue);

setItemSpecMaxIlvl(eventValueInt);
};

const handleNumberChange: HandleNumberChangeEventFunction = (
value,
numericalType
) => {
if (numericalType === "min") {
handleMinChange(value);
} else if (numericalType === "max") {
handleMaxChange(value);
} else {
throw "'numericalType' must be 'min' or 'max'";
}
};

const presetValue: DefaultMinMaxValues = {
min: itemSpec?.minIlvl != null ? itemSpec.minIlvl : undefined,
max: itemSpec?.maxIlvl != null ? itemSpec.maxIlvl : undefined,
};

return (
<MinMaxNumberInput
descriptionText={props.text}
handleNumberChange={handleNumberChange}
defaultValues={presetValue}
/>
);
const { itemSpec, setItemSpecMinIlvl, setItemSpecMaxIlvl } =
useGraphInputStore();

const handleMinChange = (eventValue: string) => {
const eventValueInt = parseInt(eventValue);

setItemSpecMinIlvl(eventValueInt);
};

const handleMaxChange = (eventValue: string) => {
const eventValueInt = parseInt(eventValue);

setItemSpecMaxIlvl(eventValueInt);
};

const handleNumberChange: HandleNumberChangeEventFunction = (
value,
numericalType,
) => {
if (numericalType === "min") {
handleMinChange(value);
} else if (numericalType === "max") {
handleMaxChange(value);
} else {
throw "'numericalType' must be 'min' or 'max'";
}
};

const presetValue: DefaultMinMaxValues = {
min: itemSpec?.minIlvl != null ? itemSpec.minIlvl : undefined,
max: itemSpec?.maxIlvl != null ? itemSpec.maxIlvl : undefined,
};

return (
<MinMaxNumberInput
descriptionText={props.text}
handleNumberChange={handleNumberChange}
defaultValues={presetValue}
autoFocus={false}
/>
);
};
Loading

0 comments on commit 2623e54

Please sign in to comment.