Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiplication and checkbox fix #194

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 63 additions & 61 deletions apps/web/app/(sidebar)/analysis/advanced/AdvancedDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,51 @@ export async function AdvancedDataTable({ id }: { id: string }) {
db
.select({
team_number: teamMatchStats.teamNumber,
auto_coral_level_1: avg(teamMatchStats.autoCoralLevel1)
.mapWith((val) => Number(val) * 3)
.as("auto_coral_level_1"),
auto_coral_level_2: avg(teamMatchStats.autoCoralLevel2)
.mapWith((val) => Number(val) * 4)
.as("auto_coral_level_2"),
auto_coral_level_3: avg(teamMatchStats.autoCoralLevel3)
.mapWith((val) => Number(val) * 6)
.as("auto_coral_level_3"),
auto_coral_level_4: avg(teamMatchStats.autoCoralLevel4)
.mapWith((val) => Number(val) * 7)
.as("auto_coral_level_4"),
auto_algae_processor: avg(teamMatchStats.autoAlgaeProcessor)
.mapWith((val) => Number(val) * 6)
.as("auto_algae_processor"),
auto_algae_net: avg(teamMatchStats.autoAlgaeNet)
.mapWith((val) => Number(val) * 4)
.as("auto_algae_net"),
teleop_coral_level_1: avg(teamMatchStats.teleopCoralLevel1)
.mapWith((val) => Number(val) * 2)
.as("teleop_coral_level_1"),
teleop_coral_level_2: avg(teamMatchStats.teleopCoralLevel2)
.mapWith((val) => Number(val) * 3)
.as("teleop_coral_level_2"),
teleop_coral_level_3: avg(teamMatchStats.teleopCoralLevel3)
.mapWith((val) => Number(val) * 4)
.as("teleop_coral_level_3"),
teleop_coral_level_4: avg(teamMatchStats.teleopCoralLevel4)
.mapWith((val) => Number(val) * 5)
.as("teleop_coral_level_4"),
teleop_algae_processor: avg(teamMatchStats.teleopAlgaeProcessor)
.mapWith((val) => Number(val) * 6)
.as("teleop_algae_processor"),
teleop_algae_net: avg(teamMatchStats.teleopAlgaeNet)
.mapWith((val) => Number(val) * 4)
.as("teleop_algae_net"),
park_percentage: avg(teamMatchStats.parkPercentage)
.mapWith((val) => Number(val) * 2)
.as("park_percentage"),
shallow_percentage: avg(teamMatchStats.shallowPercentage)
.mapWith((val) => Number(val) * 6)
.as("shallow_percentage"),
deep_percentage: avg(teamMatchStats.deepPercentage)
.mapWith((val) => Number(val) * 12)
.as("deep_percentage"),
auto_coral_level_1: avg(teamMatchStats.autoCoralLevel1).as(
"auto_coral_level_1"
),
auto_coral_level_2: avg(teamMatchStats.autoCoralLevel2).as(
"auto_coral_level_2"
),
auto_coral_level_3: avg(teamMatchStats.autoCoralLevel3).as(
"auto_coral_level_3"
),
auto_coral_level_4: avg(teamMatchStats.autoCoralLevel4).as(
"auto_coral_level_4"
),
auto_algae_processor: avg(teamMatchStats.autoAlgaeProcessor).as(
"auto_algae_processor"
),
auto_algae_net: avg(teamMatchStats.autoAlgaeNet).as(
"auto_algae_net"
),
teleop_coral_level_1: avg(teamMatchStats.teleopCoralLevel1).as(
"teleop_coral_level_1"
),
teleop_coral_level_2: avg(teamMatchStats.teleopCoralLevel2).as(
"teleop_coral_level_2"
),
teleop_coral_level_3: avg(teamMatchStats.teleopCoralLevel3).as(
"teleop_coral_level_3"
),
teleop_coral_level_4: avg(teamMatchStats.teleopCoralLevel4).as(
"teleop_coral_level_4"
),
teleop_algae_processor: avg(
teamMatchStats.teleopAlgaeProcessor
).as("teleop_algae_processor"),
teleop_algae_net: avg(teamMatchStats.teleopAlgaeNet).as(
"teleop_algae_net"
),
park_percentage: avg(teamMatchStats.parkPercentage).as(
"park_percentage"
),
shallow_percentage: avg(teamMatchStats.shallowPercentage).as(
"shallow_percentage"
),
deep_percentage: avg(teamMatchStats.deepPercentage).as(
"deep_percentage"
),
initiation_line: avg(teamMatchStats.initiationLine)
.mapWith(Number)
.as("initiation_line"),
Expand All @@ -79,26 +79,26 @@ export async function AdvancedDataTable({ id }: { id: string }) {
team_number: pointValues.team_number,
team_name: team.teamName,
auto_total: {
value: sql`${pointValues.auto_coral_level_1} +
${pointValues.auto_coral_level_2} +
${pointValues.auto_coral_level_3} +
${pointValues.auto_coral_level_4} +
${pointValues.auto_algae_processor} +
${pointValues.auto_algae_net} +
${pointValues.initiation_line}`,
value: sql`3 * ${pointValues.auto_coral_level_1} +
4 * ${pointValues.auto_coral_level_2} +
6 * ${pointValues.auto_coral_level_3} +
7 * ${pointValues.auto_coral_level_4} +
6 * ${pointValues.auto_algae_processor} +
4 * ${pointValues.auto_algae_net} +
${pointValues.initiation_line}`,
},
teleop_total: {
value: sql`${pointValues.teleop_coral_level_1} +
${pointValues.teleop_coral_level_2} +
${pointValues.teleop_coral_level_3} +
${pointValues.teleop_coral_level_4} +
${pointValues.teleop_algae_processor} +
${pointValues.teleop_algae_net}`,
value: sql`2 * ${pointValues.teleop_coral_level_1} +
3 * ${pointValues.teleop_coral_level_2} +
4 * ${pointValues.teleop_coral_level_3} +
5 * ${pointValues.teleop_coral_level_4} +
6 * ${pointValues.teleop_algae_processor} +
4 * ${pointValues.teleop_algae_net}`,
},
endgame_total: {
value: sql`${pointValues.park_percentage} +
${pointValues.shallow_percentage} +
${pointValues.deep_percentage}`,
value: sql`2 * ${pointValues.park_percentage} +
6 * ${pointValues.shallow_percentage} +
12 * ${pointValues.deep_percentage}`,
},
})
.from(pointValues)
Expand All @@ -117,6 +117,8 @@ export async function AdvancedDataTable({ id }: { id: string }) {
Number(team.endgame_total.value),
}));

console.log(formattedData.filter((team) => team.team_number === 10120));

return (
<div>
<AdvancedDataTableClient advancedData={formattedData} />
Expand Down
7 changes: 5 additions & 2 deletions apps/web/app/(sidebar)/scout/form/steps/AutoPeriod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Checkbox } from "@repo/ui/components/checkbox";
import { FormField, FormItem, FormLabel } from "@repo/ui/components/form";
import { useFormContext } from "react-hook-form";


export function AutoPeriod() {
const form = useFormContext();

Expand All @@ -19,7 +18,11 @@ export function AutoPeriod() {
name="auto.auto_initiation_line"
render={({ field }) => (
<FormItem className="flex items-center gap-x-2 mb-2">
<Checkbox className="size-6 mb-0" {...field} />
<Checkbox
className="size-6 mb-0"
checked={field.value}
onCheckedChange={field.onChange}
/>
<FormLabel className="text-sm flex items-center gap-2">
Moved off black line?
</FormLabel>
Expand Down