Compare commits
5 Commits
feat/oil-p
...
fix/hourly
| Author | SHA1 | Date | |
|---|---|---|---|
| bf29551a31 | |||
| a8c9c2252f | |||
| 6baecfc2bf | |||
| a0de8fa7f3 | |||
| 0ce14352f1 |
@@ -18,12 +18,14 @@ spec:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
BACKUP_DIR=/data/backups
|
||||
mkdir -p $BACKUP_DIR
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
# Backup SQLite database using .backup for consistency
|
||||
sqlite3 /data/oil_calculator.db ".backup '$BACKUP_DIR/oil_calculator_${DATE}.db'"
|
||||
echo "Backup done: $BACKUP_DIR/oil_calculator_${DATE}.db ($(du -h $BACKUP_DIR/oil_calculator_${DATE}.db | cut -f1))"
|
||||
DST="$BACKUP_DIR/oil_calculator_${DATE}.db"
|
||||
# Consistent snapshot via Python's sqlite3 .backup API (sqlite3 CLI not in image)
|
||||
python3 -c "import sqlite3; s=sqlite3.connect('/data/oil_calculator.db'); d=sqlite3.connect('$DST'); s.backup(d); d.close(); s.close()"
|
||||
echo "Backup done: $DST ($(du -h $DST | cut -f1))"
|
||||
# Keep last 48 backups (2 days of hourly)
|
||||
ls -t $BACKUP_DIR/oil_calculator_*.db | tail -n +49 | xargs rm -f 2>/dev/null
|
||||
echo "Backups retained: $(ls $BACKUP_DIR/oil_calculator_*.db | wc -l)"
|
||||
|
||||
@@ -267,8 +267,9 @@ async function exportExcel(mode) {
|
||||
const unit = oils.unitLabel(i.oil)
|
||||
return `${i.oil} ${i.drops}${unit}`
|
||||
}).join('、')
|
||||
const vol = volumeLabel(r)
|
||||
ws.addRow([
|
||||
r.name,
|
||||
vol ? `${r.name}(${vol})` : r.name,
|
||||
(r.tags || []).join('/'),
|
||||
ingredientStr,
|
||||
calcMaxTimes(r),
|
||||
@@ -287,8 +288,9 @@ async function exportExcel(mode) {
|
||||
for (const r of ka.recipes) {
|
||||
const price = getSellingPrice(r._id)
|
||||
const margin = calcMargin(r.kitCost, price)
|
||||
const vol = volumeLabel(r)
|
||||
ws.addRow([
|
||||
r.name,
|
||||
vol ? `${r.name}(${vol})` : r.name,
|
||||
calcMaxTimes(r),
|
||||
Number(r.kitCost.toFixed(2)),
|
||||
Number(r.originalCost.toFixed(2)),
|
||||
@@ -326,7 +328,8 @@ async function exportExcel(mode) {
|
||||
|
||||
for (const row of crossComparison.value) {
|
||||
const price = getSellingPrice(row.id)
|
||||
const vals = [row.name]
|
||||
const vol = volumeLabel(row)
|
||||
const vals = [vol ? `${row.name}(${vol})` : row.name]
|
||||
if (mode === 'full') vals.push((row.tags || []).join('/'))
|
||||
for (const ka of kitAnalysis.value) {
|
||||
const cost = row.costs[ka.id]
|
||||
|
||||
Reference in New Issue
Block a user