Merge branch 'main' of https://git.d-popov.com/popov/mwhitnessing
This commit is contained in:
@ -1,12 +1,13 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
nextjs-app: # https://sofia.mwitnessing.com/
|
nextjs-app: # https://sofia.mwhitnessing.com/
|
||||||
hostname: jwpw-app-staging # jwpw-nextjs-app-1
|
hostname: jwpw-app-staging # jwpw-nextjs-app-1
|
||||||
image: docker.d-popov.com/jwpw:latest
|
image: docker.d-popov.com/jwpw:latest
|
||||||
volumes:
|
volumes:
|
||||||
- /mnt/docker_volumes/pw-demo/app/public/content/uploads/:/app/public/content/uploads
|
- /mnt/docker_volumes/pw-demo/app/public/content/uploads/:/app/public/content/uploads
|
||||||
|
- /mnt/docker_volumes/pw-demo/app/logs:/app/logs
|
||||||
environment:
|
environment:
|
||||||
- APP_ENV=test
|
- APP_ENV=test.staging
|
||||||
- NODE_ENV=test
|
- NODE_ENV=test
|
||||||
- TZ=Europe/Sofia
|
- TZ=Europe/Sofia
|
||||||
- DATABASE=mysql://jwpwsofia_demo:dwxhns9p9vp248@mariadb-demo:3306/jwpwsofia_demo
|
- DATABASE=mysql://jwpwsofia_demo:dwxhns9p9vp248@mariadb-demo:3306/jwpwsofia_demo
|
||||||
@ -14,12 +15,13 @@ services:
|
|||||||
- GIT_BRANCH=main
|
- GIT_BRANCH=main
|
||||||
- GIT_USERNAME=deploy
|
- GIT_USERNAME=deploy
|
||||||
- GIT_PASSWORD=L3Kr2R438u4F7
|
- GIT_PASSWORD=L3Kr2R438u4F7
|
||||||
command: sh -c " cd /app && npm install && npx next build && npm run nodeenv; tail -f /dev/null"
|
command: sh -c " cd /app && npm install && npx next build && npm run start-env; tail -f /dev/null"
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infrastructure_default
|
- infrastructure_default
|
||||||
|
- default
|
||||||
mariadb:
|
mariadb:
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
@ -33,6 +35,9 @@ services:
|
|||||||
MYSQL_DATABASE: jwpwsofia_demo
|
MYSQL_DATABASE: jwpwsofia_demo
|
||||||
MYSQL_USER: jwpwsofia_demo
|
MYSQL_USER: jwpwsofia_demo
|
||||||
MYSQL_PASSWORD: dwxhns9p9vp248
|
MYSQL_PASSWORD: dwxhns9p9vp248
|
||||||
|
# networks:
|
||||||
|
# - infrastructure_default
|
||||||
|
# - default
|
||||||
networks:
|
networks:
|
||||||
infrastructure_default:
|
infrastructure_default:
|
||||||
external: true
|
external: true
|
@ -168,10 +168,12 @@ export const getServerSideProps = async (context) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const prisma = common.getPrismaClient();
|
const prisma = common.getPrismaClient();
|
||||||
const monthInfo = common.getMonthInfo(new Date());
|
let today = new Date();
|
||||||
//minus 1 day from the firstMonday to get the last Sunday
|
today.setHours(0, 0, 0, 0);
|
||||||
const lastSunday = new Date(monthInfo.firstMonday);
|
// const monthInfo = common.getMonthInfo(today);
|
||||||
lastSunday.setDate(lastSunday.getDate() - 1);
|
// //minus 1 day from the firstMonday to get the last Sunday
|
||||||
|
// const lastSunday = new Date(monthInfo.firstMonday);
|
||||||
|
// lastSunday.setDate(lastSunday.getDate() - 1);
|
||||||
const publisher = await prisma.publisher.findUnique({
|
const publisher = await prisma.publisher.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: session.user.id,
|
id: session.user.id,
|
||||||
@ -179,7 +181,7 @@ export const getServerSideProps = async (context) => {
|
|||||||
some: {
|
some: {
|
||||||
shift: {
|
shift: {
|
||||||
startTime: {
|
startTime: {
|
||||||
gte: lastSunday,
|
gte: today,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -208,7 +210,7 @@ export const getServerSideProps = async (context) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const assignments = publisher?.assignments.filter(a => a.shift.startTime >= lastSunday && a.shift.isPublished) || [];
|
const assignments = publisher?.assignments.filter(a => a.shift.startTime >= today && a.shift.isPublished) || [];
|
||||||
|
|
||||||
|
|
||||||
const transformedAssignments = assignments?.sort((a, b) => a.shift.startTime - b.shift.startTime)
|
const transformedAssignments = assignments?.sort((a, b) => a.shift.startTime - b.shift.startTime)
|
||||||
|
@ -204,13 +204,24 @@ export const getServerSideProps = async (context) => {
|
|||||||
var items = await dataHelper.getCalendarEvents(session.user.id);
|
var items = await dataHelper.getCalendarEvents(session.user.id);
|
||||||
// common.convertDatesToISOStrings(items);
|
// common.convertDatesToISOStrings(items);
|
||||||
//serializable dates
|
//serializable dates
|
||||||
items = items.map(item => ({
|
items = items.map(item => {
|
||||||
...item,
|
const updatedItem = {
|
||||||
startTime: item.startTime.toISOString(),
|
...item,
|
||||||
endTime: item.endTime.toISOString(),
|
startTime: item.startTime.toISOString(),
|
||||||
date: item.date.toISOString(),
|
endTime: item.endTime.toISOString(),
|
||||||
}));
|
date: item.date.toISOString()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (updatedItem.shift) {
|
||||||
|
updatedItem.shift = {
|
||||||
|
...updatedItem.shift,
|
||||||
|
startTime: updatedItem.shift.startTime.toISOString(),
|
||||||
|
endTime: updatedItem.shift.endTime.toISOString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return updatedItem;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
@ -647,6 +647,7 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig
|
|||||||
assignments: {
|
assignments: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
// publisherId: true,
|
||||||
shift: {
|
shift: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@ -689,15 +690,13 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig
|
|||||||
date: new Date(item.shift.startTime),
|
date: new Date(item.shift.startTime),
|
||||||
startTime: new Date(item.shift.startTime),
|
startTime: new Date(item.shift.startTime),
|
||||||
endTime: new Date(item.shift.endTime),
|
endTime: new Date(item.shift.endTime),
|
||||||
publisherId: item.publisherid,
|
// publisherId: item.publisherId,
|
||||||
|
publisherId: publisher.id,
|
||||||
type: "assignment",
|
type: "assignment",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user