loadEntity loadEntityVersion and loadMultiple all should ignore entityCache

This commit is contained in:
Bryan Housel
2017-08-24 21:00:39 -04:00
parent cd05c51432
commit b7d98b94fb
2 changed files with 17 additions and 10 deletions
+9 -4
View File
@@ -267,13 +267,15 @@ export default {
loadEntity: function(id, callback) {
var type = osmEntity.id.type(id),
osmID = osmEntity.id.toOSM(id);
osmID = osmEntity.id.toOSM(id),
options = { cache: false };
this.loadFromAPI(
'/api/0.6/' + type + '/' + osmID + (type !== 'node' ? '/full' : ''),
function(err, entities) {
if (callback) callback(err, { data: entities });
}
},
options
);
},
@@ -295,16 +297,19 @@ export default {
loadMultiple: function(ids, callback) {
var that = this;
_.each(_.groupBy(_.uniq(ids), osmEntity.id.type), function(v, k) {
var type = k + 's',
osmIDs = _.map(v, osmEntity.id.toOSM);
osmIDs = _.map(v, osmEntity.id.toOSM),
options = { cache: false };
_.each(_.chunk(osmIDs, 150), function(arr) {
that.loadFromAPI(
'/api/0.6/' + type + '?' + type + '=' + arr.join(),
function(err, entities) {
if (callback) callback(err, { data: entities });
}
},
options
);
});
});
+8 -6
View File
@@ -321,13 +321,14 @@ describe('iD.serviceOsm', function () {
server.respond();
});
it('ignores repeat requests using entityCache', function(done) {
it('does not ignore repeat requests', function(done) {
var id = 'n1';
connection.loadEntity(id, function(err, result) {
var entity = _.find(result.data, function(e) { return e.id === id; });
expect(entity).to.be.an.instanceOf(iD.Node);
connection.loadEntity(id, function(err, result) {
expect(result.data).to.eql([]);
connection.loadEntity(id, function(err1, result1) {
var entity1 = _.find(result1.data, function(e1) { return e1.id === id; });
expect(entity1).to.be.an.instanceOf(iD.Node);
connection.loadEntity(id, function(err2, result2) {
var entity2 = _.find(result2.data, function(e2) { return e2.id === id; });
expect(entity2).to.be.an.instanceOf(iD.Node);
done();
});
server.respond();
@@ -411,6 +412,7 @@ describe('iD.serviceOsm', function () {
it('loads nodes');
it('loads ways');
it('does not ignore repeat requests');
});