mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-11-02 21:41:28 +08:00
Add migration to store frequencies in database
This commit is contained in:
@ -80,9 +80,7 @@ Template.metadata.helpers({
|
|||||||
},
|
},
|
||||||
rank() {
|
rank() {
|
||||||
const glyph = Session.get('editor.glyph');
|
const glyph = Session.get('editor.glyph');
|
||||||
if (!glyph) return '?';
|
return (glyph && glyph.metadata.frequency) || '?';
|
||||||
const data = cjklib.getCharacterData(glyph.character);
|
|
||||||
return data.frequency || '?';
|
|
||||||
},
|
},
|
||||||
references() {
|
references() {
|
||||||
const glyph = Session.get('editor.glyph');
|
const glyph = Session.get('editor.glyph');
|
||||||
|
|||||||
@ -7,7 +7,10 @@ const defaultGlyph = (character) => {
|
|||||||
return {
|
return {
|
||||||
character: character,
|
character: character,
|
||||||
codepoint: character.codePointAt(0),
|
codepoint: character.codePointAt(0),
|
||||||
metadata: {kangxi_index: data.kangxi_index},
|
metadata: {
|
||||||
|
frequency: data.frequency,
|
||||||
|
kangxi_index: data.kangxi_index,
|
||||||
|
},
|
||||||
stages: {},
|
stages: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const addFrequencyField = (glyph) => {
|
||||||
|
const data = cjklib.getCharacterData(glyph.character);
|
||||||
|
glyph.metadata.frequency = data.frequency;
|
||||||
|
Glyphs.save(glyph);
|
||||||
|
}
|
||||||
|
|
||||||
const checkStrokeExtractorStability = (glyph) => {
|
const checkStrokeExtractorStability = (glyph) => {
|
||||||
const strokes = stroke_extractor.getStrokes(
|
const strokes = stroke_extractor.getStrokes(
|
||||||
glyph.stages.path, glyph.stages.bridges);
|
glyph.stages.path, glyph.stages.bridges);
|
||||||
@ -36,6 +42,7 @@ const migrateOldGlyphSchemaToNew = (glyph) => {
|
|||||||
codepoint: codepoint,
|
codepoint: codepoint,
|
||||||
metadata: {
|
metadata: {
|
||||||
definition: undefined,
|
definition: undefined,
|
||||||
|
frequency: data.frequency,
|
||||||
kangxi_index: data.kangxi_index,
|
kangxi_index: data.kangxi_index,
|
||||||
pinyin: undefined,
|
pinyin: undefined,
|
||||||
strokes: undefined,
|
strokes: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user