Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

10-scores.js 933B

1234567891011121314151617181920212223242526272829
  1. const aspects = require('../generated/prescore_matrix.json')
  2. exports.seed = function (knex) {
  3. // Deletes ALL existing entries
  4. return knex('prescored_aspects')
  5. .truncate()
  6. .then(function () {
  7. let rowCount = 1
  8. const makeRow = scores => {
  9. scoreMap = {}
  10. scores.forEach((score, i) => {
  11. scoreMap['aspect_id'] = rowCount
  12. scoreMap[i + 1] = score
  13. })
  14. return scoreMap
  15. }
  16. const rows = []
  17. Object.values(aspects).forEach(rowOfScores => {
  18. if(Array.isArray(rowOfScores)) {
  19. const row = makeRow(rowOfScores)
  20. rows.push(row)
  21. rowCount++
  22. }
  23. })
  24. // Inserts seed entries
  25. return knex('prescored_aspects').insert(rows)
  26. })
  27. }