Skip to content

Commit

Permalink
Fix ticket sync from Drupal (#734)
Browse files Browse the repository at this point in the history
* 1. Removed requirement for barcode to exist in Drupal ticket
2. Made barcode column nullable
  • Loading branch information
eladlachmi authored Mar 8, 2018
1 parent 8213ae7 commit d3bfdac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
16 changes: 16 additions & 0 deletions migrations/20180308221834_ticket_barcode_nullable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

exports.up = function(knex, Promise) {
return Promise.all([
knex.schema.alterTable('tickets', t => {
t.string('barcode', 32).nullable().alter()
})
])
};

exports.down = function(knex, Promise) {
return Promise.all([
knex.schema.alterTable('tickets', t => {
t.string('barcode', 32).notNullable().alter()
})
])
};
9 changes: 2 additions & 7 deletions scripts/drupal_ticket_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ async function updateTicket(ticket) {
ticket_type
} = ticket;

if (typeof barcode !== 'string' || barcode.length === 0) {
log.info('No barcode for ticket', ticket_id, 'user ', holder_email);
return;
} else {
log.info('Updating ticket', ticket_id, 'user ', holder_email);
}
log.info('Updating ticket', ticket_id, 'user ', holder_email);

try {
var user = await User.forge({email: holder_email}).fetch();
Expand Down Expand Up @@ -198,7 +193,7 @@ async function updateTicket(ticket) {
sparkTicket = Ticket.forge({
event_id: EVENT_ID,
holder_id: holder_id,
barcode: barcode,
barcode: (typeof barcode !== 'string' || barcode.length === 0) ? null : barcode,
order_id: order_id,
ticket_id: ticket_id,
type: ticket_type,
Expand Down

0 comments on commit d3bfdac

Please sign in to comment.