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