Skip to content

Commit

Permalink
Sandbox 2017 (#464)
Browse files Browse the repository at this point in the history
* move to sandbox event id

* version v2.10.0

* Update drupal_ticket_sync.js

* addding all ticket ids

* disable snyk-protect
  • Loading branch information
LeonFedotov authored Oct 5, 2017
1 parent 5a7ace3 commit e08c2eb
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 146 deletions.
2 changes: 1 addition & 1 deletion models/camp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var Camp = bookshelf.Model.extend({

// let _camps_members = constants.CAMP_MEMBERS_TABLE_NAME;
// let _users = constants.USERS_TABLE_NAME;
let query = "SELECT users.*,camp_members.status AS member_status,SUM(IF(tickets.ticket_id>0,1,0)) AS ticket_count,SUM(tickets.inside_event) AS inside_event FROM users inner join camp_members on users.user_id=camp_members.user_id left join tickets on tickets.holder_id=users.user_id and tickets.event_id='MIDBURN2017' where camp_members.camp_id=" + this.attributes.id + " group by users.user_id";
let query = "SELECT users.*,camp_members.status AS member_status,SUM(IF(tickets.ticket_id>0,1,0)) AS ticket_count,SUM(tickets.inside_event) AS inside_event FROM users inner join camp_members on users.user_id=camp_members.user_id left join tickets on tickets.holder_id=users.user_id and tickets.event_id='SANDBOX2017' where camp_members.camp_id=" + this.attributes.id + " group by users.user_id";
return knex //(_users)
.raw(query)
// .select(_users + '.*', _camps_members + '.status AS member_status'/*,'tickets.ticket_id'*/)
Expand Down
44 changes: 28 additions & 16 deletions models/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ const ticketType = {
ADULT_DIRECT_SALE_TICKET: '43',
YOUTH_TICKET: '44',
LOW_INCOME_TICKET: '45',
INTERNATIONAL_DIRECT_SALE: '46'
INTERNATIONAL_DIRECT_SALE: '46',
SANDBOX2017_ADULT_TICKET: '49',
SANDBOX2017_TICKET_A: '50',
SANDBOX2017_TICKET_B: '51',
SANDBOX2017_TICKET_C: '52'
};

// TODO We should not use enums like this at all!! Add ticket_types table to DB
Expand All @@ -88,6 +92,14 @@ const events = {
ticketType.LOW_INCOME_TICKET,
ticketType.INTERNATIONAL_DIRECT_SALE
]
},
SANDBOX2017: {
bundles: [
ticketType.SANDBOX2017_ADULT_TICKET,
ticketType.SANDBOX2017_TICKET_A,
ticketType.SANDBOX2017_TICKET_B,
ticketType.SANDBOX2017_TICKET_C
]
}
};

Expand All @@ -96,27 +108,27 @@ module.exports = {
// -- system constant --
// note: Future release will change the event_id
// TODO We should not use this constant. We need to implement a mechanism that will allow the user to change the current event from the UI, therefore we can't rely on constant!
CURRENT_EVENT_ID: "MIDBURN2017",
CURRENT_EVENT_ID: 'SANDBOX2017',
events,

// -- table names --
EVENTS_TABLE_NAME: "events",
USERS_TABLE_NAME: "users",
PAYMENTS_TABLE_NAME: "payments",
NPO_MEMBERS_TABLE_NAME: "npo_members",
CAMPS_TABLE_NAME: "camps",
CAMP_MEMBERS_TABLE_NAME: "camp_members",
DRUPAL_USERS_TABLE_NAME: "drupal_users",
TICKETS_TABLE_NAME: "tickets",
EVENTS_TABLE_NAME: 'events',
USERS_TABLE_NAME: 'users',
PAYMENTS_TABLE_NAME: 'payments',
NPO_MEMBERS_TABLE_NAME: 'npo_members',
CAMPS_TABLE_NAME: 'camps',
CAMP_MEMBERS_TABLE_NAME: 'camp_members',
DRUPAL_USERS_TABLE_NAME: 'drupal_users',
TICKETS_TABLE_NAME: 'tickets',

prototype_camps: prototype_camps,

VOL_DEPARTMENTS_TABLE_NAME: "vol_departments",
VOLUNTEERS_TABLE_NAME: "volunteers",
VOL_DEPARTMENT_ROLES_TABLE_NAME: "vol_departments_roles",
VOL_TYPES_IN_SHIFT_TABLE_NAME: "vol_types_in_shift",
VOL_SHIFTS_TABLE_NAME: "vol_shifts",
VOL_SCHEDULE_TABLE_NAME: "vol_schedule",
VOL_DEPARTMENTS_TABLE_NAME: 'vol_departments',
VOLUNTEERS_TABLE_NAME: 'volunteers',
VOL_DEPARTMENT_ROLES_TABLE_NAME: 'vol_departments_roles',
VOL_TYPES_IN_SHIFT_TABLE_NAME: 'vol_types_in_shift',
VOL_SHIFTS_TABLE_NAME: 'vol_shifts',
VOL_SCHEDULE_TABLE_NAME: 'vol_schedule',

// -- enums --

Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"this is part of the deployment proess, so it is important to update the version number",
"version name corresponds to the github release name / tag name - https://github.com/Midburn/Spark/releases"
],
"version": "2.9.1",
"version": "2.10.0",
"private": true,
"scripts": {
"postinstall": "bower install",
Expand All @@ -28,9 +28,7 @@
"lint": "./node_modules/.bin/eslint .",
"//createdb": "bootstraps MySql with a clean spark database & user",
"createdb": "mysql -u root < migrations/create_db.sql",
"create_test_db": "cross-env SPARK_DB_DBNAME=spark_test mysql -u root --protocol=tcp < migrations/create_test_db.sql && cross-env SPARK_DB_DBNAME=spark_test knex migrate:latest",
"snyk-protect": "snyk protect",
"prepublish": "npm run snyk-protect"
"create_test_db": "cross-env SPARK_DB_DBNAME=spark_test mysql -u root --protocol=tcp < migrations/create_test_db.sql && cross-env SPARK_DB_DBNAME=spark_test knex migrate:latest"
},
"dependencies": {
"async": "^2.1.4",
Expand Down
4 changes: 2 additions & 2 deletions routes/api_camps_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ module.exports = (app, passport) => {
}
}
if (req.user.isAdmin) {
let query = "SELECT camps.__prototype, SUM(IF(camp_members.status IN ('approved','approved_mgr'),1,0)) AS total FROM camps LEFT JOIN camp_members ON camps.id=camp_members.camp_id WHERE camps.event_id='MIDBURN2017' GROUP BY __prototype;";
let query = "SELECT camps.__prototype, SUM(IF(camp_members.status IN ('approved','approved_mgr'),1,0)) AS total FROM camps LEFT JOIN camp_members ON camps.id=camp_members.camp_id WHERE camps.event_id='SANDBOX2017' GROUP BY __prototype;";
let query1 = "SELECT " +
"count(*) AS total_tickets" +
",SUM(inside_event) AS inside_event " +
Expand All @@ -930,7 +930,7 @@ module.exports = (app, passport) => {
",SUM( IF(entrance_timestamp>=NOW() - INTERVAL 1 HOUR,1,0)) AS last_1h_entrance " +
",SUM( IF(last_exit_timestamp>=NOW() - INTERVAL 1 HOUR,1,0)) AS last_1h_exit " +
"FROM tickets " +
"WHERE tickets.event_id='MIDBURN2017' " +
"WHERE tickets.event_id='SANDBOX2017' " +
"GROUP BY event_id; ";
if (req.user.isAdmin) {
let stat = {};
Expand Down
6 changes: 3 additions & 3 deletions routes/gate_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var Event = require('../models/event').Event;
var constants = require('../models/constants');

router.get('/', userRole.isGateManager(), function (req, res) {
//TODO Temp MIDBURN2017, we need to add a global current-event selector.
Event.forge({event_id: 'MIDBURN2017'}).fetch().then(event => {
//TODO Temp SANDBOX2017, we need to add a global current-event selector.
Event.forge({event_id: 'SANDBOX2017'}).fetch().then(event => {
return res.render('pages/gate', {
gate_code: event.attributes.gate_code
});
Expand Down Expand Up @@ -63,7 +63,7 @@ router.get('/ajax/tickets', [security.protectJwt, userRole.isGateManager()], asy

router.get('/gate-statistics', userRole.isGateManager(), async (req, res) => {

const event_id = 'MIDBURN2017';
const event_id = 'SANDBOX2017';
let event = await Event.forge({event_id: event_id}).fetch();

let totalCounter = await knex('tickets')
Expand Down
4 changes: 2 additions & 2 deletions scripts/drupal_ticket_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ var log = require('../libs/logger')(module);

var User = require('../models/user.js').User;
var Ticket = require('../models/ticket.js').Ticket;
const TICKETS_TYPE_IDS = [39, 40, 41, 43, 44, 45, 46];
const TICKETS_TYPE_IDS = [39, 40, 41, 43, 44, 45, 46, 49, 50, 51, 52];
const STATUS_COMPLETED = 'Completed';

const EVENT_ID = "MIDBURN2017";
const EVENT_ID = "SANDBOX2017";
var globalMinutesDelta = 0;

function r(options) {
Expand Down
Loading

0 comments on commit e08c2eb

Please sign in to comment.