fix
All checks were successful
Build And Deploy Main / build-and-deploy (push) Successful in 33s

This commit is contained in:
2026-03-09 15:17:38 -04:00
parent a3e3b37914
commit dd3a690cb4
4 changed files with 43 additions and 61 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -98,34 +98,62 @@ jobs:
SSH_CMD="ssh -i $SSH_KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
RSYNC_RSH="ssh -i $SSH_KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
CHANGE_PATHS=(app/controllers app/middlewares app/models app/routes app/scheduler app/services)
CHANGED_LIST_FILE="$(mktemp)"
DELETED_LIST_FILE="$(mktemp)"
DIRS_LIST_FILE="$(mktemp)"
is_excluded_path() {
case "$1" in
*.DS_Store|*/.DS_Store|_MACOSX|_MACOSX/*|*/_MACOSX|*/_MACOSX/*) return 0 ;;
*) return 1 ;;
esac
}
if [ -n "$BEFORE_SHA" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
CHANGED_FILES=$(git diff --name-only "$BEFORE_SHA" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" | rg -v "$EXCLUDE_PATTERN" || true)
DELETED_FILES=$(git diff --name-only --diff-filter=D "$BEFORE_SHA" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" | rg -v "$EXCLUDE_PATTERN" || true)
while IFS= read -r file; do
[ -z "$file" ] && continue
is_excluded_path "$file" && continue
printf '%s\n' "$file" >> "$CHANGED_LIST_FILE"
done < <(git diff --name-only --diff-filter=ACMRT "$BEFORE_SHA" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" || true)
while IFS= read -r file; do
[ -z "$file" ] && continue
is_excluded_path "$file" && continue
printf '%s\n' "$file" >> "$DELETED_LIST_FILE"
done < <(git diff --name-only --diff-filter=D "$BEFORE_SHA" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" || true)
else
CHANGED_FILES=$(git show --name-only --pretty="" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" | rg -v "$EXCLUDE_PATTERN" || true)
DELETED_FILES=""
while IFS= read -r file; do
[ -z "$file" ] && continue
is_excluded_path "$file" && continue
[ -f "$file" ] || continue
printf '%s\n' "$file" >> "$CHANGED_LIST_FILE"
done < <(git show --name-only --pretty="" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" || true)
fi
if [ -z "$CHANGED_FILES" ]; then
if [ ! -s "$CHANGED_LIST_FILE" ]; then
echo "No backend file changes detected in target folders."
else
while IFS= read -r file; do
[ -z "$file" ] && continue
[ -f "$file" ] || continue
remote_file="$REMOTE_APP_ROOT/$file"
remote_dir=$(dirname "$remote_file")
$SSH_CMD "$REMOTE_USER@$REMOTE_HOST" "sudo mkdir -p \"$remote_dir\""
rsync -az --exclude ".DS_Store" --exclude "_MACOSX" --rsync-path="sudo rsync" -e "$RSYNC_RSH" "$file" "$REMOTE_USER@$REMOTE_HOST:$remote_file"
echo "Deployed: $file"
done <<< "$CHANGED_FILES"
printf '%s\n' "$(dirname "$file")"
done < "$CHANGED_LIST_FILE" | awk '!seen[$0]++' > "$DIRS_LIST_FILE"
while IFS= read -r dir; do
[ -z "$dir" ] && continue
$SSH_CMD "$REMOTE_USER@$REMOTE_HOST" "sudo mkdir -p \"$REMOTE_APP_ROOT/$dir\""
done < "$DIRS_LIST_FILE"
rsync -az --files-from="$CHANGED_LIST_FILE" --exclude ".DS_Store" --exclude "_MACOSX" --rsync-path="sudo rsync" -e "$RSYNC_RSH" ./ "$REMOTE_USER@$REMOTE_HOST:$REMOTE_APP_ROOT/"
echo "Deployed backend changes from CHANGE_PATHS."
fi
if [ -n "$DELETED_FILES" ]; then
if [ -s "$DELETED_LIST_FILE" ]; then
while IFS= read -r file; do
[ -z "$file" ] && continue
remote_file="$REMOTE_APP_ROOT/$file"
$SSH_CMD "$REMOTE_USER@$REMOTE_HOST" "sudo rm -f \"$remote_file\""
echo "Deleted on remote: $file"
done <<< "$DELETED_FILES"
done < "$DELETED_LIST_FILE"
fi
rm -f "$CHANGED_LIST_FILE" "$DELETED_LIST_FILE" "$DIRS_LIST_FILE"

BIN
app/.DS_Store vendored

Binary file not shown.

View File

@@ -48,8 +48,6 @@ const RoutesDashboard = () => {
const [routesForShowing, setRoutesForShowing] = useState(allRoutes);
const [routesInboundForShowing, setRoutesInboundForShowing] = useState(inboundRoutes);
const [routesOutboundForShowing, setRoutesOutboundForShowing] = useState(outboundRoutes);
const previousAbsentCustomerIdsRef = useRef(new Set());
const isUpdatingAbsentRef = useRef(false);
const [isLoading, setIsLoading] = useState(false);
const [errorMessage, setErrorMessage] = useState(undefined);
@@ -481,50 +479,6 @@ const RoutesDashboard = () => {
});
});
// Only update backend if absent customer list has changed and not already updating
const previousIds = previousAbsentCustomerIdsRef.current;
const hasAbsentCustomersChanged =
absentCustomerIds.size !== previousIds.size ||
[...absentCustomerIds].some(id => !previousIds.has(id)) ||
[...previousIds].some(id => !absentCustomerIds.has(id));
if (hasAbsentCustomersChanged && !isUpdatingAbsentRef.current) {
// Update ref immediately (synchronous) to prevent re-entry
previousAbsentCustomerIdsRef.current = absentCustomerIds;
isUpdatingAbsentRef.current = true;
// Collect routes that need updating
const routesToUpdate = [];
outboundRoutes.forEach(outboundRoute => {
const filteredCustomerList = outboundRoute.route_customer_list?.filter(customer =>
!absentCustomerIds.has(customer.customer_id)
) || [];
if (filteredCustomerList.length !== outboundRoute.route_customer_list?.length) {
routesToUpdate.push({
id: outboundRoute.id,
data: { ...outboundRoute, route_customer_list: filteredCustomerList }
});
}
});
// Batch update via direct API calls, then refetch once
if (routesToUpdate.length > 0) {
Promise.all(routesToUpdate.map(r => TransRoutesService.updateRoute(r.id, r.data)))
.then(() => {
dispatch(fetchAllRoutes());
})
.catch(err => {
console.error('Error batch-updating outbound routes:', err);
})
.finally(() => {
isUpdatingAbsentRef.current = false;
});
} else {
isUpdatingAbsentRef.current = false;
}
}
// Remove absent customers from outbound routes for display
const processedOutboundRoutes = outboundRoutes.map(outboundRoute => ({
...outboundRoute,
@@ -534,7 +488,7 @@ const RoutesDashboard = () => {
}));
return processedOutboundRoutes;
}, [dispatch, fetchAllRoutes])
}, [])
useEffect(() => {
setPageLoading(true);