Skip to content

Commit f56b368

Browse files
authored
Handle doc lookup where id not found, and remove problematic hash-to-query addon (#592)
* Handle doc lookup where id not found, and remove problematic hash-to-query addon * Prevent double fetch when a call find with namespace type fails
1 parent 30fea8d commit f56b368

File tree

5 files changed

+20
-48
lines changed

5 files changed

+20
-48
lines changed

app/adapters/application.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ export default JSONAPIAdapter.extend({
3434
modelNameToUse = 'namespace';
3535
}
3636

37-
let encodedRevId = encodeURIComponent(revId);
38-
url = `json-docs/${projectName}/${version}/${pluralize(modelNameToUse)}/${encodedRevId}`;
37+
if (typeof revId != 'undefined') {
38+
let encodedRevId = encodeURIComponent(revId);
39+
url = `json-docs/${projectName}/${version}/${pluralize(modelNameToUse)}/${encodedRevId}`;
40+
} else {
41+
throw new Error('Documentation item not found');
42+
}
3943
} else if (modelName === 'missing') {
4044
let version = this.get('projectService.version');
4145
let revId = this.get('metaStore').getRevId(projectName, version, modelName, id);

app/routes/project-version/classes/class.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@ export default Route.extend(ScrollTracker, {
2929

3030
find(typeName, param) {
3131
return this.store.find(typeName, param).catch((e1) => {
32-
Logger.warn(e1, 'fetching by class or module failed, retrying as namespace');
33-
return this.store.find('namespace', param).catch((e2) => {
34-
Logger.error(e2);
35-
return resolve({ isError: true });
32+
if (typeName != 'namespace') {
33+
Logger.warn(e1, 'fetching by class or module failed, retrying as namespace');
34+
return this.store.find('namespace', param).catch((e2) => {
35+
Logger.error(e2);
36+
return resolve({
37+
isError: true,
38+
status: 404
39+
});
40+
});
41+
}
42+
Logger.error(e1);
43+
return resolve({
44+
isError: true,
45+
status: 404
3646
});
3747
});
3848
},

lib/hash-to-query/index.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

lib/hash-to-query/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,5 @@
106106
"npm": "5"
107107
},
108108
"cacheDirectories": ["bower_components", "node_modules"],
109-
"ember-addon": {
110-
"paths": ["lib/hash-to-query"]
111-
},
112109
"fastbootDependencies": ["algoliasearch"]
113110
}

0 commit comments

Comments
 (0)