Skip to content

Commit c5712b9

Browse files
committed
Some fixes and tweaks for the public pages. Almost working again.
1 parent 5a8a06d commit c5712b9

File tree

4 files changed

+97
-94
lines changed

4 files changed

+97
-94
lines changed

api/controllers/pages/invite/inviteController.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ export async function getFutureTourns(req,res){
276276
endLimit = ` limit ${req.query.limit} `;
277277
}
278278

279-
const future = await db.sequelize.query(`
279+
const futureTourns = await db.sequelize.query(`
280280
select
281281
CONCAT(tourn.id, '-', '0') as id,
282282
tourn.id tournId, tourn.webname, tourn.name, tourn.tz,
283+
'No' as district,
283284
tourn.city as location, tourn.state, tourn.country,
284285
tourn.start start,
285286
tourn.end end,
@@ -288,7 +289,7 @@ export async function getFutureTourns(req,res){
288289
msnats.value as msnats,
289290
nats.value as nats,
290291
closed.value as closed,
291-
count(distinct school.id) as schoolcount,
292+
count(distinct school.id) as schoolCount,
292293
YEAR(tourn.start) as year,
293294
WEEK(CONVERT_TZ(tourn.start, '+00:00', tourn.tz), 3) as week,
294295
GROUP_CONCAT(DISTINCT(circuit.abbr) SEPARATOR ', ') as circuits,
@@ -403,7 +404,7 @@ export async function getFutureTourns(req,res){
403404
)
404405
405406
group by tourn.id
406-
order by tourn.end, schoolcount DESC
407+
order by tourn.end, schoolCount DESC
407408
${ endLimit }
408409
`, {
409410
type : db.sequelize.QueryTypes.SELECT,
@@ -413,14 +414,14 @@ export async function getFutureTourns(req,res){
413414
select
414415
CONCAT(tourn.id, '-', weekend.id) as id,
415416
tourn.id tournId, tourn.webname, tourn.name, tourn.tz,
416-
weekend.id as districts,
417+
'Yes' as district,
417418
weekend.id weekendId, weekend.name weekendName, weekend.city as location, weekend.state, tourn.country,
418419
site.name site,
419420
weekend.start start,
420421
weekend.end end,
421422
weekend.reg_end regEnd,
422423
weekend.reg_start regStart,
423-
count(distinct school.id) as schoolcount,
424+
count(distinct school.id) as schoolCount,
424425
YEAR(weekend.start) as year,
425426
WEEK(CONVERT_TZ(weekend.start, '+00:00', tourn.tz), 3) as week,
426427
GROUP_CONCAT(DISTINCT(circuit.abbr) SEPARATOR ', ') as circuits,
@@ -528,14 +529,14 @@ export async function getFutureTourns(req,res){
528529
type : db.sequelize.QueryTypes.SELECT,
529530
});
530531

531-
future.push(...futureDistricts);
532+
futureTourns.push(...futureDistricts);
532533

533534
const shortOptions = {
534535
month : 'numeric',
535536
day : 'numeric',
536537
};
537538

538-
const formattedFuture = future.map( (tourn) => {
539+
const formattedFutureTourns = futureTourns.map( (tourn) => {
539540

540541
// These functions will feel like something the frontend should do. But
541542
// no, in order to enable searching and filtering, they must be in the
@@ -545,7 +546,7 @@ export async function getFutureTourns(req,res){
545546
tourn.week = thisWeekDT;
546547
}
547548

548-
tourn.sortnumeric = parseInt(`${tourn.year}${tourn.week.toString().padStart(2, '0')}${9999999 - tourn.schoolcount}`);
549+
tourn.sortnumeric = parseInt(`${tourn.year}${tourn.week.toString().padStart(2, '0')}${9999999 - tourn.schoolCount}`);
549550
const tournStart = convertTZ(tourn.start, tourn.tz);
550551
const tournEnd = convertTZ(tourn.end, tourn.tz);
551552
tourn.tzCode = shortZone(tourn.tz);
@@ -587,24 +588,22 @@ export async function getFutureTourns(req,res){
587588
eventTypes,
588589
fullDates: tournDateRange.fullOutput,
589590
};
590-
});
591-
592-
formattedFuture.sort( (a, b) => {
591+
}).sort( (a, b) => {
593592
return a.sortnumeric - b.sortnumeric;
594593
});
595594

596595
// I have to do this separately because I pull the Districts weekends as
597596
// separate things from individual tournaments.
598597

599598
if (req.query.limit > 0) {
600-
if (future.length > req.query.limit) {
601-
future.length = req.query.limit;
599+
if (formattedFutureTourns.length > req.query.limit) {
600+
formattedFutureTourns.length = req.query.limit;
602601
}
603-
} else if (future.length > 256) {
604-
future.length = 256;
602+
} else if (formattedFutureTourns.length > 512) {
603+
formattedFutureTourns.length = 512;
605604
}
606605

607-
return res.status(200).json(formattedFuture);
606+
return res.status(200).json(formattedFutureTourns);
608607
}
609608

610609
getFutureTourns.openapi = {

api/controllers/rest/eventController.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ export async function getScheduleByEvent(req,res) {
103103

104104
export async function getEventByAbbr(req, res){
105105

106+
if (!req.params.eventId) {
107+
return NotFound(req, res, `No valid eventID sent`);
108+
}
109+
106110
const eventData = await db.sequelize.query(`
107111
select
108112
event.name eventName,

api/data/models/sweep_event.js

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,82 @@ import _sequelize from 'sequelize';
22
const { Model, Sequelize } = _sequelize;
33

44
export default class sweepEvent extends Model {
5-
static init(sequelize, DataTypes) {
6-
return sequelize.define('sweepEvent', {
7-
id: {
8-
autoIncrement: true,
9-
type: DataTypes.INTEGER,
10-
allowNull: false,
11-
primaryKey: true
12-
},
13-
sweep_set: {
14-
type: DataTypes.INTEGER,
15-
allowNull: true,
16-
references: {
17-
model: 'sweep_set',
18-
key: 'id'
19-
}
20-
},
21-
event: {
22-
type: DataTypes.INTEGER,
23-
allowNull: true,
24-
references: {
25-
model: 'event',
26-
key: 'id'
27-
}
28-
},
29-
event_type: {
30-
type: DataTypes.ENUM('all','congress','debate','speech','wsdc','wudc'),
31-
allowNull: true
32-
},
33-
event_level: {
34-
type: DataTypes.ENUM('all','open','jv','novice','champ','es-open','es-novice','middle'),
35-
allowNull: true
36-
},
37-
nsda_category: {
38-
type: DataTypes.INTEGER,
39-
allowNull: true
40-
references: {
41-
model: 'nsda_category',
42-
key: 'id',
43-
}
44-
},
45-
sweep_award_event: {
46-
type: DataTypes.INTEGER,
47-
allowNull: true
48-
},
49-
timestamp: {
50-
type: DataTypes.DATE,
51-
allowNull: false,
52-
defaultValue: Sequelize.Sequelize.fn('current_timestamp')
5+
static init(sequelize, DataTypes) {
6+
return sequelize.define('sweepEvent', {
7+
id : {
8+
autoIncrement : true,
9+
type : DataTypes.INTEGER,
10+
allowNull : false,
11+
primaryKey : true
12+
},
13+
sweep_set: {
14+
type : DataTypes.INTEGER,
15+
allowNull : true,
16+
references : {
17+
model : 'sweep_set',
18+
key : 'id'
5319
}
54-
}, {
55-
tableName: 'sweep_event',
56-
timestamps: false,
57-
indexes: [
58-
{
59-
name: "PRIMARY",
60-
unique: true,
61-
using: "BTREE",
62-
fields: [
63-
{ name: "id" },
64-
]
65-
},
66-
{
67-
name: "sweep_set",
68-
using: "BTREE",
69-
fields: [
70-
{ name: "sweep_set" },
71-
]
72-
},
73-
{
74-
name: "event",
75-
using: "BTREE",
76-
fields: [
77-
{ name: "event" },
78-
]
79-
},
80-
]
81-
});
20+
},
21+
event: {
22+
type: DataTypes.INTEGER,
23+
allowNull: true,
24+
references: {
25+
model: 'event',
26+
key: 'id'
27+
}
28+
},
29+
event_type: {
30+
type: DataTypes.ENUM('all','congress','debate','speech','wsdc','wudc'),
31+
allowNull: true
32+
},
33+
event_level: {
34+
type: DataTypes.ENUM('all','open','jv','novice','champ','es-open','es-novice','middle'),
35+
allowNull: true
36+
},
37+
nsda_category: {
38+
type: DataTypes.INTEGER,
39+
allowNull: true,
40+
references: {
41+
model: 'nsda_category',
42+
key: 'id',
43+
}
44+
},
45+
sweep_award_event: {
46+
type: DataTypes.INTEGER,
47+
allowNull: true
48+
},
49+
timestamp: {
50+
type: DataTypes.DATE,
51+
allowNull: false,
52+
defaultValue: Sequelize.Sequelize.fn('current_timestamp')
8253
}
54+
}, {
55+
tableName: 'sweep_event',
56+
timestamps: false,
57+
indexes: [
58+
{
59+
name: "PRIMARY",
60+
unique: true,
61+
using: "BTREE",
62+
fields: [
63+
{ name: "id" },
64+
]
65+
},
66+
{
67+
name: "sweep_set",
68+
using: "BTREE",
69+
fields: [
70+
{ name: "sweep_set" },
71+
]
72+
},
73+
{
74+
name: "event",
75+
using: "BTREE",
76+
fields: [
77+
{ name: "event" },
78+
]
79+
},
80+
]
81+
});
82+
}
8383
}

api/repos/eventRepo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function getEventInvites(tournId) {
4646
select
4747
event.id, event.abbr, event.name, event.fee, event.type,
4848
event.nsda_category nsdaCategory,
49-
nsda_category.name nsdaCategoryName
49+
nsda_category.name nsdaCategoryName,
5050
category.id categoryId, category.name categoryName, category.abbr categoryAbbr,
5151
judge_field_report.value judgeFieldReport,
5252
cap.value cap,
@@ -58,7 +58,7 @@ export async function getEventInvites(tournId) {
5858
live_updates.value liveUpdates,
5959
description.value_text description,
6060
currency.value currency,
61-
count(entry.id) as entryCount,
61+
count(entry.id) as entryCount
6262
6363
from (event, category)
6464

0 commit comments

Comments
 (0)