Anpassung an Training ohne Riegen und Geburtstags-Check korrigiert

This commit is contained in:
Klaas Börgmann 2024-11-26 13:04:17 +01:00
parent 0bd0b21256
commit f30664340b
2 changed files with 14 additions and 21 deletions

24
app.js
View File

@ -101,12 +101,19 @@ const isBirthday = (birthdate, date, previousTraining) => {
let adjustedBirthdate = new Date(birthdate);
adjustedBirthdate.setFullYear(date.getFullYear());
if (adjustedBirthdate === date) {
if (adjustedBirthdate.getMonth() == 10) {
console.log("checking:", adjustedBirthdate, date, previousTraining);
}
if (adjustedBirthdate.getTime() === date.getTime()) {
console.log("birthday");
return 2;
}
if (adjustedBirthdate >= previousTraining && adjustedBirthdate <= date) {
console.log("had birthday", adjustedBirthdate, date, previousTraining);
if (
adjustedBirthdate.getTime() >= previousTraining.getTime() &&
adjustedBirthdate.getTime() <= date.getTime()
) {
console.log("had birthday");
return 1;
}
return 0;
@ -146,7 +153,6 @@ const getTraining = async (kw, jahr) => {
`,
[kw, jahr]
);
return result.rows[0];
};
@ -757,7 +763,6 @@ ORDER BY r.riegennummer, t.geburtsdatum ASC;
anzahl,
});
});
if (training) {
training.datum = getdayOfWeek(training.kw, training.jahr);
}
@ -946,17 +951,12 @@ app.post("/update-mitglied", requireAdmin, async (req, res) => {
} = req.body;
try {
if (type == "tel") {
console.log(
"INSERT INTO telefonnummern (fid_teilnehmer, name, verbindung, nummer, stand) VALUES ($1, $2, $3, $4, $5)",
[id, name, verbindung, nummer, moment().toDate()]
);
await pool.query(
"INSERT INTO telefonnummern (fid_teilnehmer, name, verbindung, nummer, stand) VALUES ($1, $2, $3, $4, $5)",
[id, name, verbindung, nummer, moment().toDate()]
);
} else if (type == "tel-delete") {
await pool.query("DELETE FROM telefonnummern WHERE id = $1", [telid]);
console.log("delete numer $1", [telid]);
} else if (type == "adresse") {
await pool.query(
"UPDATE teilnehmende SET vorname = $1, nachname = $2, geburtsdatum = $3, adresse = $4, probe = $5, helfer = $6 WHERE id = $7",
@ -1008,7 +1008,6 @@ app.get("/spiele", async (req, res) => {
app.post("/delete-spiel", requireAdmin, async (req, res) => {
const { spielId } = req.body;
console.log(spielId);
await pool.query("DELETE FROM spiele WHERE id = $1", [spielId]);
res.redirect("/spiele");
});
@ -1116,7 +1115,6 @@ app.post("/anwesend", requireAuth, async (req, res) => {
anw = [anw];
}
for (const teilnehmer of anw) {
console.log(teilnehmer);
const Tnresult = await pool.query(
"SELECT *From anwesend WHERE fid_teilnehmer = $1 AND fid_training=$2",
[teilnehmer, trainingId]
@ -1169,12 +1167,10 @@ app.get("/feature", requireAuth, async (req, res) => {
app.post("/feature", requireAdmin, async (req, res) => {
const { title, body, type, urgency, user } = req.body;
console.log(user);
const userResult = await pool.query(
"SELECT id FROM users WHERE username = $1",
[user]
);
console.log(userResult.rows[0].id);
try {
await pool.query(
"INSERT INTO features (title, body, type, urgency, fid_user) VALUES ($1, $2, $3, $4, $5);",

View File

@ -10,8 +10,7 @@
<% } %>
</h1>
</div>
<!-- Nav tabs -->
<!-- Nav tabs
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link <%= activeTab === 'spiel' ? 'active' : '' %>" id="tab-spiel" data-bs-toggle="tab" data-bs-target="#spiel" type="button" role="tab" aria-controls="spiel" aria-selected="false">Spiel</button>
@ -19,10 +18,11 @@
<button class="nav-link <%= activeTab === 'anwesend' ? 'active' : '' %>" id="tab-anwesend" data-bs-toggle="tab" data-bs-target="#anwesend" type="button" role="tab" aria-controls="anwesend" aria-selected="false">Anwesenheit</button>
</li>
</ul>
-->
<% if (training) { %>
<div class="tab-pane fade <%= activeTab === 'spiel' ? 'show active' : '' %>" id="spiel" role="tabpanel" aria-labelledby="tab-spiel">
<div id="spiel">
<h3>Spiel: </h3>
@ -139,9 +139,6 @@
<% } %>
</div>
</div>
<div class="tab-pane fade <%= activeTab === 'anwesend' ? 'show active' : '' %>" id="anwesend" role="tabpanel" aria-labelledby="tab-anwesend">
<h3>Anwesenheit</h3>
<p>Anwesend: <%= anwesend.length %></p>
<!-- Nav tabs -->
@ -265,7 +262,7 @@
</div>
</div>
<% } else { %>