All files / source/i18n information.js

100% Statements 6/6
100% Branches 1/1
100% Functions 4/4
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41        2x           1x                           1x   1x       1x 1x                  
import I18nDao from '../../database/dao/i18n';
import { sequelize, models } from '../../../config/database';
 
async function getI18n(query) {
  return I18nDao.findI18n(query, {
    raw: true,
  });
}
 
async function getI18nNewKey(query = {}) {
  return I18nDao.findI18ns(query, {
    raw: true,
    attributes: [
      [
        sequelize.literal(
          `CONCAT('BEE', MAX(CAST(SUBSTRING(${models.I18n.rawAttributes.key.field}, 4, length(${models.I18n.rawAttributes.key.field})-3) AS UNSIGNED)))`
        ),
        'key',
      ],
    ],
  });
}
 
async function getAllI18ns() {
  const i18ns = await I18nDao.findI18ns({}, { raw: true });
 
  return i18ns;
}
 
async function getLastDateUpdatedI18n() {
  const lastDate = await I18nDao.getLastDateUpdatedI18n();
  return lastDate;
}
 
export default {
  getI18n,
  getAllI18ns,
  getI18nNewKey,
  getLastDateUpdatedI18n,
};