Skip to content

Commit

Permalink
feat: Linking balsa to ZSP
Browse files Browse the repository at this point in the history
  • Loading branch information
1grzyb1 committed Mar 28, 2024
1 parent c364110 commit df3c034
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions odyseja-ui/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export type PunctationCells = {
dt: string,
style: string,
penalty: string,
balsa: string;
}

export type SakRequest = {
Expand Down
15 changes: 13 additions & 2 deletions odyseja-ui/src/routes/panel/gad/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import {getGadStatus, runGad, stopGadRun} from "./gadService";
import {type Progress, type GadRequest, Status, type PunctationCells} from "$lib/types.js";
import {type GadRequest, type Progress, type PunctationCells, Status} from "$lib/types.js";
import {onDestroy, onMount} from "svelte";
import {ProgressBar} from "@skeletonlabs/skeleton";
Expand All @@ -23,7 +23,12 @@
});
function updateProblemPunctuationCells(index, field, value) {
let cell = data.problemPunctuationCells[index] || {dt: '', style: '', penalty: ''} as PunctationCells;
let cell = data.problemPunctuationCells[index] || {
dt: '',
style: '',
penalty: '',
balsa: ''
} as PunctationCells;
cell[field] = value;
data.problemPunctuationCells[index] = cell;
}
Expand Down Expand Up @@ -65,6 +70,12 @@
value="{data.problemPunctuationCells[i]?.penalty ?? ''}"
on:input={(e) => updateProblemPunctuationCells(i, 'penalty', e.target.value)}
placeholder="Komórka Punktów karnych"/>
{#if i === 4}
<input class="input flex-grow flex-1" type="text"
value="{data.problemPunctuationCells[i]?.balsa ?? ''}"
on:input={(e) => updateProblemPunctuationCells(i, 'balsa', e.target.value)}
placeholder="Balsa"/>
{/if}
</div>
{/each}

Expand Down
12 changes: 10 additions & 2 deletions src/main/kotlin/odyseja/odysejapka/gad/GadRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ internal class GadRunner(
val values = listOf(
getZspValue(file.id, cells.dt),
getZspValue(file.id, cells.style),
getZspValue(file.id, cells.penalty)
getZspValue(file.id, cells.penalty),
getBalsaValue(file.id, cells.balsa)
)
sheetsAdapter.writeZsp("I${team.zspRow}:K${team.zspRow}", values, sheetTitle)
sheetsAdapter.writeZsp("K${team.zspRow}:N${team.zspRow}", values, sheetTitle)
println("Created: ${file.name}")
}
}
Expand All @@ -61,6 +62,13 @@ internal class GadRunner(
return "=importrange(\"https://docs.google.com/spreadsheets/d/$sheetId\";\"Arkusz Ocen Surowych!$cell\")"
}

private fun getBalsaValue(sheetId: String, cell: String?): String {
if (cell.isNullOrBlank()) {
return ""
}
return "=importrange(\"https://docs.google.com/spreadsheets/d/$sheetId\";\"Arkusz Ocen Cząstkowych!$cell\")"
}

private fun templateCell(sheetId: String, cell: String, value: String) {
val cellValue = sheetsAdapter.getCellValue(cell, sheetId)
sheetsAdapter.writeCell(cell, cellValue.replace("XXX", value), sheetId)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/odyseja/odysejapka/gad/PunctationCells.kt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
data class PunctationCells(val dt: String, val style: String, val penalty: String)
data class PunctationCells(val dt: String, val style: String, val penalty: String, val balsa: String?)
2 changes: 1 addition & 1 deletion src/main/kotlin/odyseja/odysejapka/sak/SakRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class SakRunner(
sheetsAdapter.writeValue(
zspId,
team.zspSheet!!,
"M${team.zspRow}",
"O${team.zspRow}",
getZspValue(sheetId, sheetName, "${pointsCell.first}${pointsCell.second}")
)
processedTeamsCount.incrementAndGet()
Expand Down

0 comments on commit df3c034

Please sign in to comment.