You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Clean up
This commit is contained in:
@@ -29,13 +29,40 @@ class BaseItem extends BaseModel {
|
||||
}
|
||||
|
||||
throw new Error('Invalid class name: ' + name);
|
||||
}
|
||||
|
||||
// if (!this.classes_) this.classes_ = {};
|
||||
// if (this.classes_[name]) return this.classes_[name];
|
||||
// let filename = name.toLowerCase();
|
||||
// if (name == 'NoteTag') filename = 'note-tag';
|
||||
// this.classes_[name] = require('lib/models/' + filename + '.js')[name];
|
||||
// return this.classes_[name];
|
||||
static async stats() {
|
||||
let output = {
|
||||
items: {},
|
||||
total: {},
|
||||
};
|
||||
|
||||
let itemCount = 0;
|
||||
let syncedCount = 0;
|
||||
for (let i = 0; i < BaseItem.syncItemDefinitions_.length; i++) {
|
||||
let d = BaseItem.syncItemDefinitions_[i];
|
||||
let ItemClass = this.getClass(d.className);
|
||||
let o = {
|
||||
total: await ItemClass.count(),
|
||||
synced: await ItemClass.syncedCount(),
|
||||
};
|
||||
output.items[d.className] = o;
|
||||
itemCount += o.total;
|
||||
syncedCount += o.synced;
|
||||
}
|
||||
|
||||
output.total = {
|
||||
total: itemCount,
|
||||
synced: syncedCount,
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static async syncedCount() {
|
||||
const ItemClass = this.itemClass(this.modelType());
|
||||
const r = await this.db().selectOne('SELECT count(*) as total FROM `' + ItemClass.tableName() + '` WHERE updated_time > sync_time');
|
||||
return r.total;
|
||||
}
|
||||
|
||||
static systemPath(itemOrId) {
|
||||
@@ -248,12 +275,6 @@ class BaseItem extends BaseModel {
|
||||
|
||||
}
|
||||
|
||||
// import { Note } from 'lib/models/note.js';
|
||||
// import { Folder } from 'lib/models/folder.js';
|
||||
// import { Resource } from 'lib/models/resource.js';
|
||||
// import { Tag } from 'lib/models/tag.js';
|
||||
// import { NoteTag } from 'lib/models/note-tag.js';
|
||||
|
||||
// Also update:
|
||||
// - itemsThatNeedSync()
|
||||
// - syncedItems()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { BaseModel } from 'lib/base-model.js';
|
||||
import { Log } from 'lib/log.js';
|
||||
import { Folder } from 'lib/models/folder.js';
|
||||
import { GeolocationReact } from 'lib/geolocation-react.js';
|
||||
import { BaseItem } from 'lib/models/base-item.js';
|
||||
import { Setting } from 'lib/models/setting.js';
|
||||
import { shim } from 'lib/shim.js';
|
||||
import moment from 'moment';
|
||||
import lodash from 'lodash';
|
||||
|
||||
@@ -96,11 +96,11 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static updateGeolocation(noteId) {
|
||||
Log.info('Updating lat/long of note ' + noteId);
|
||||
this.logger().info('Updating lat/long of note ' + noteId);
|
||||
|
||||
let geoData = null;
|
||||
return GeolocationReact.currentPosition().then((data) => {
|
||||
Log.info('Got lat/long');
|
||||
return shim.Geolocation.currentPosition().then((data) => {
|
||||
this.logger().info('Got lat/long');
|
||||
geoData = data;
|
||||
return Note.load(noteId);
|
||||
}).then((note) => {
|
||||
@@ -110,7 +110,7 @@ class Note extends BaseItem {
|
||||
note.altitude = geoData.coords.altitude;
|
||||
return Note.save(note);
|
||||
}).catch((error) => {
|
||||
Log.info('Cannot get location:', error);
|
||||
this.logger().warn('Cannot get location:', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user