Add migration to store frequencies in database

This commit is contained in:
Shaunak Kishore
2015-11-28 13:24:59 -05:00
parent 3c956bd055
commit cdf4faae98
3 changed files with 12 additions and 4 deletions

View File

@ -80,9 +80,7 @@ Template.metadata.helpers({
},
rank() {
const glyph = Session.get('editor.glyph');
if (!glyph) return '?';
const data = cjklib.getCharacterData(glyph.character);
return data.frequency || '?';
return (glyph && glyph.metadata.frequency) || '?';
},
references() {
const glyph = Session.get('editor.glyph');

View File

@ -7,7 +7,10 @@ const defaultGlyph = (character) => {
return {
character: character,
codepoint: character.codePointAt(0),
metadata: {kangxi_index: data.kangxi_index},
metadata: {
frequency: data.frequency,
kangxi_index: data.kangxi_index,
},
stages: {},
}
}

View File

@ -1,5 +1,11 @@
"use strict";
const addFrequencyField = (glyph) => {
const data = cjklib.getCharacterData(glyph.character);
glyph.metadata.frequency = data.frequency;
Glyphs.save(glyph);
}
const checkStrokeExtractorStability = (glyph) => {
const strokes = stroke_extractor.getStrokes(
glyph.stages.path, glyph.stages.bridges);
@ -36,6 +42,7 @@ const migrateOldGlyphSchemaToNew = (glyph) => {
codepoint: codepoint,
metadata: {
definition: undefined,
frequency: data.frequency,
kangxi_index: data.kangxi_index,
pinyin: undefined,
strokes: undefined,