{"size": 947, "ext": "js", "max_stars_repo_path": "fix-records.js", "max_stars_repo_name": "Reekoh/rf-pass", "max_stars_repo_stars_event_min_datetime": "2021-05-19T00:58:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-19T00:58:07.000Z", "max_issues_repo_path": "fix-records.js", "max_issues_repo_name": "Reekoh/rf-pass", "max_issues_repo_issues_event_min_datetime": "2017-03-21T03:44:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-03-21T03:44:16.000Z", "max_forks_repo_path": "fix-records.js", "max_forks_repo_name": "Reekoh/rf-pass", "max_forks_repo_forks_event_min_datetime": "2017-01-16T05:47:15.000Z", "max_forks_repo_forks_event_max_datetime": "2017-03-16T07:40:37.000Z"}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": 3, "avg_line_length": 24.2820512821, "max_line_length": 79, "alphanum_fraction": 0.6642027455}
'use strict';

let db = require('./services/local-db');
let path = require('path');
let async = require('async');

db.connect({
	path: path.join(__dirname, 'db', 'rb.db'),
	machineCode: process.env.MACHINE_CODE
}, function (err) {
	if (err) {
		console.log('Local DB Connection Failed.', err);
		throw err;
	}

	db.getAllParticipants(function (err, participants) {
		if (err) {
			console.log('Failed retrieving all participant records.', err);
			throw err;
		}

		async.each(participants, function (participant, done) {
			if (!participant || !participant.id || !participant.rfid_tag) return done();

			let tag = participant.rfid_tag;
			tag = participant.rfid_tag.toUpperCase();

			db.updateParticipantTag(participant.id, tag, done);
		}, function (err) {
			if (err) {
				console.log('Failed retrieving all participant records.', err);
				throw err;
			}

			console.log('Updated all participant tags.');
			process.exit(0);
		});
	});
});