<commit_before>/*
 * Meteor Startup:
 * For running appliction startup code
*/

Meteor.startup(() => {

  if (!Meteor.isServer)
    return;

  // Check for Admin account
  let adminUser = Meteor.users.findOne({roles: 'admin'});

  if (adminUser === undefined) {
    if (Meteor.settings.admin === undefined) {
        Meteor.logger.error("No \"admin\" object found in \"Meteor.settings\"");
        process.exit(1);
    }
    else if (Meteor.settings.admin.username === undefined) {
        Meteor.logger.error("No \"username\" field found in \"Meteor.settings.admin\"");
        process.exit(1);
    }
    else if (Meteor.settings.admin.email === undefined) {
        Meteor.logger.error("No \"email\" field found in \"Meteor.settings.admin\"");
        process.exit(1);
    }
    else if (Meteor.settings.admin.password === undefined) {
        Meteor.logger.error("No \"password\" field found in \"Meteor.settings.admin\"");
        process.exit(1);
    }

    const { username, password, firstname, lastname, name } = Meteor.settings.admin;

    const adminId = Accounts.createUser({
      username,
      password,
      firstname,
      lastname,
      name,
      roles: ['user', 'admin', 'volunteer'],
      updatedAt: new Date(),
    });

    Accounts.addEmail(adminId, Meteor.settings.admin.email, true);

    adminUser = Meteor.users.findOne({ roles: 'admin' });
    Meteor.logger.info("New Admin User: ");
  } else {
    Meteor.logger.info("Found Admin User: ");
  }
  Meteor.logger.logobj(adminUser);


  // const ONE_HOUR = 3600000;
  // const ONE_SEC = 1000;

  // // Check every 15 seconds.
  // Meteor.setInterval(() => {

  //     let gameState = GameState.findOne({});
  //     if (!gameState.gameplay)
  //         return; // Game not one - don't check for puzzles.

  //     console.log('Checking For Timed Out Puzzles');
  //     // Game ON Check For Puzzles out of time
  //     let attempts = PuzzleAttempts.find({finishTime: null}).fetch();

  //     for (let i = 0; i < attempts.length; i++) {
  //         // Is this Puzzle Attempt out of time?
  //         let attempt = attempts[i];
  //         if (Date.now() - attempt.startTime.getTime() >= ONE_HOUR) {
  //             PuzzleAttempts.update({_id: attempt._id}, {$set: {
  //                 finishTime: new Date(),
  //                 finalScore: (2 * ONE_HOUR)
  //             }});
  //         }
  //     }
  // }, ONE_SEC * 15);

});<commit_msg>Make default admin user schema reflect normal user fields<commit_after>/*
 * Meteor Startup:
 * For running appliction startup code
*/
import { cloneDeep } from 'lodash';

Meteor.startup(() => {

  if (!Meteor.isServer)
    return;

  // Check for Admin account
  let adminUser = Meteor.users.findOne({ roles: 'admin' });

  if (adminUser === undefined) {

    if (!Meteor.settings.admin) {
      Meteor.logger.error('No "admin" object found in "Meteor.settings"');
      process.exit(1);
    }

    const adminProps = cloneDeep(Meteor.settings.admin);
    adminProps.updatedAt = new Date();

    const adminId = Accounts.createUser(adminProps);
    Accounts.addEmail(adminId, Meteor.settings.admin.email, true);

    adminUser = Meteor.users.findOne({ roles: 'admin' });
    Meteor.logger.info("New Admin User: ");

  } else {
    Meteor.logger.info("Found Admin User: ");
  }

  Meteor.logger.logobj(adminUser);

  // const ONE_HOUR = 3600000;
  // const ONE_SEC = 1000;

  // // Check every 15 seconds.
  // Meteor.setInterval(() => {

  //     let gameState = GameState.findOne({});
  //     if (!gameState.gameplay)
  //         return; // Game not one - don't check for puzzles.

  //     console.log('Checking For Timed Out Puzzles');
  //     // Game ON Check For Puzzles out of time
  //     let attempts = PuzzleAttempts.find({finishTime: null}).fetch();

  //     for (let i = 0; i < attempts.length; i++) {
  //         // Is this Puzzle Attempt out of time?
  //         let attempt = attempts[i];
  //         if (Date.now() - attempt.startTime.getTime() >= ONE_HOUR) {
  //             PuzzleAttempts.update({_id: attempt._id}, {$set: {
  //                 finishTime: new Date(),
  //                 finalScore: (2 * ONE_HOUR)
  //             }});
  //         }
  //     }
  // }, ONE_SEC * 15);

});
{'fraction_non_alphanumeric': 0.16086547507055504, 'fraction_numerical': 0.009172154280338664, 'mean_word_length': 2.2317629179331306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4073230', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1324, 'n_words': 318}