Skip to content

Commit

Permalink
Merge branch 'stage'
Browse files Browse the repository at this point in the history
  • Loading branch information
ekate committed Apr 30, 2020
2 parents 0a8bffe + d73e95d commit d4b1d23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions source/json/curl.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ module.exports = exports = {
"dest" : "source/json/datasources/subjectCount.json"
},
"categoryQueryEn" : {
"src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&q=sm_collection_code:aco&fq=sm_topic:*&facet=true&rows=0&facet.query=%7B!key=%22General%20Works%22%7Dss_call_number:A*&facet.query=%7B!key=%22Philosophy.%20Psychology.%20Religion%22%7Dss_call_number:B*&facet.query=%7B!key=%22Auxiliary%20Sciences%20of%20History%22%7Dss_call_number:C*&facet.query=%7B!key=%22World%20History%20and%20History%20of%20Europe,%20Asia,%20Africa,%20Australia,%20New%20Zealand,%20etc..%22%7Dss_call_number:D*&facet.query=%7B!key=%22History%20of%20the%20Americas%22%7Dss_call_number:(E*%20OR%20F*)&facet.query=%7B!key=%22Geography.%20Anthropology.%20Recreation%22%7Dss_call_number:G*&facet.query=%7B!key=%22Social%20Sciences%22%7Dss_call_number:H*&facet.query=%7B!key=%22Political%20Science%22%7Dss_call_number:J*&facet.query=%7B!key=%22Law%22%7Dss_call_number:K*&facet.query=%7B!key=%22Education%22%7Dss_call_number:L*&facet.query=%7B!key=%22Music%20and%20Books%20on%20Music%22%7Dss_call_number:M*&facet.query=%7B!key=%22Fine%20Arts%22%7Dss_call_number:N*&facet.query=%7B!key=%22Language%20and%20Literature%22%7Dss_call_number:P*&facet.query=%7B!key=%22Science%22%7Dss_call_number:Q*&facet.query=%7B!key=%22Medicine%22%7Dss_call_number:R*&facet.query=%7B!key=%22Agriculture%22%7Dss_call_number:S*&facet.query=%7B!key=%22Technology%22%7Dss_call_number:T*&facet.query=%7B!key=%22Military%20Science%22%7Dss_call_number:U*&facet.query=%7B!key=%22Naval%20Science%22%7Dss_call_number:V*&facet.query=%7B!key=%22Bibliography.%20Library%20Science,%20Information%20Resources%20(General)%22%7Dss_call_number:Z*`,
"src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&q=sm_collection_code:aco&fq=sm_topic:*&facet=true&rows=0&facet.field=sm_topic`,
"dest" : "source/json/datasources/categoryQueryEn.json"
},
"categoryQueryAr" : {
"src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&wt=json&json.nl=arrmap&q=sm_ar_topic:*&facet=true&rows=0&facet.query=%7B!key=%22%D8%A7%D9%84%D9%85%D8%B9%D8%A7%D8%B1%D9%81%20%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9%22%7Dss_call_number:A*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%81%D9%84%D8%B3%D9%81%D8%A9%20%D9%88%D8%B9%D9%84%D9%85%20%D8%A7%D9%84%D9%86%D9%81%D8%B3%20%D9%88%D8%A7%D9%84%D8%AF%D9%8A%D9%86%22%7Dss_call_number:B*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D9%81%D8%B1%D8%B9%D9%8A%D8%A9%20%D9%84%D9%84%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%22%7Dss_call_number:C*&facet.query=%7B!key=%22%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%20%D8%A7%D9%84%D8%B9%D8%A7%D9%84%D9%85%20%D9%88%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%20%D8%A3%D9%88%D8%B1%D9%88%D8%A8%D8%A7%20%D9%88%D8%A2%D8%B3%D9%8A%D8%A7%20%D9%88%D8%A3%D9%81%D8%B1%D9%8A%D9%82%D9%8A%D8%A7%22%7Dss_call_number:D*&facet.query=%7B!key=%22%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%20%D8%A3%D9%85%D8%B1%D9%8A%D9%83%D8%A7%22%7Dss_call_number:(E*%20OR%20F*)&facet.query=%7B!key=%22%D8%A7%D9%84%D8%AC%D8%BA%D8%B1%D8%A7%D9%81%D9%8A%D8%A7%20%D9%88%D8%A7%D9%84%D8%A3%D9%86%D8%AB%D8%B1%D8%A8%D9%88%D9%84%D9%88%D8%AC%D9%8A%D8%A7%20%D9%88%D8%A7%D9%84%D8%AA%D8%B1%D9%81%D9%8A%D9%87%22%7Dss_call_number:G*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A9%22%7Dss_call_number:H*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%B3%D9%8A%D8%A7%D8%B3%D9%8A%D8%A9%22%7Dss_call_number:J*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%82%D8%A7%D9%86%D9%88%D9%86%22%7Dss_call_number:K*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%AA%D8%B9%D9%84%D9%8A%D9%85%22%7Dss_call_number:L*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%85%D9%88%D8%B3%D9%8A%D9%82%D9%89%22%7Dss_call_number:M*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%81%D9%86%D9%88%D9%86%20%D8%A7%D9%84%D8%AC%D9%85%D9%8A%D9%84%D8%A9%22%7Dss_call_number:N*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%84%D8%BA%D8%A7%D8%AA%20%D9%88%D8%A7%D9%84%D8%A2%D8%AF%D8%A7%D8%A8%22%7Dss_call_number:P*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%22%7Dss_call_number:Q*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B7%D8%A8%22%7Dss_call_number:R*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B2%D8%B1%D8%A7%D8%B9%D8%A9%22%7Dss_call_number:S*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%AA%D9%83%D9%86%D9%88%D9%84%D9%88%D8%AC%D9%8A%D8%A7%22%7Dss_call_number:T*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%B9%D8%B3%D9%83%D8%B1%D9%8A%D8%A9%22%7Dss_call_number:U*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%A8%D8%AD%D8%B1%D9%8A%D8%A9%22%7Dss_call_number:V*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%A8%D8%A8%D9%84%D9%8A%D9%88%D8%BA%D8%B1%D8%A7%D9%81%D9%8A%D8%A7%20%D8%8C%20%D9%88%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D9%85%D9%83%D8%AA%D8%A8%D8%A7%D8%AA%20%D8%8C%20%D9%88%D8%A7%D9%84%D9%85%D8%B9%D9%84%D9%88%D9%85%D8%A7%D8%AA%20%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9%22%7Dss_call_number:Z*`,
"src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&q=sm_collection_code:aco&fq=sm_ar_topic:*&facet=true&rows=0&facet.field=sm_ar_topic`,
"dest" : "source/json/datasources/categoryQueryAr.json"
}
}
Expand Down
16 changes: 11 additions & 5 deletions source/json/pages/browsebycategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,36 @@ module.exports = async function browsebycategory () {
// check if datasource file exists
if (grunt.file.isFile(datasourcesFilepath)) {
const data = await grunt.file.readJSON(datasourcesFilepath);
// Get Object keys and organize the data in a more meaningful way
return Object.keys(data.facet_counts.facet_queries).map(category => {
// Get Object keys and organize the data in a more meaningful way. TODO: add checks for malformed response
var fd = ( language === 'En') ? Object.values(data.facet_counts.facet_fields.sm_topic) : Object.values(data.facet_counts.facet_fields.sm_ar_topic);
console.log(fd);

return fd.map(category => {
return {
category: category,
category: Object.keys(category),
// build link
uri: encodeURI(`${appUrl}/search?category=${category}&scope=matches`),
uri: encodeURI(`${appUrl}/search?category=${Object.keys(category)}&scope=matches`),
// format count number e.g., 1,000 instead of 1000.
count: toNumberWithCommas(data.facet_counts.facet_queries[category]),
count: toNumberWithCommas(Object.values(category)),
// label (en/ar) used to prefix the books count
prefixLabel: prefixLabel[language],
};
});
}
}
catch (error) {
console.log("here 1");
grunt.fail.warn(error);
}
}

try {
const frontCount = await frontCountFromCache();
let categoriesEn = await categoriesFromCache('En');
//console.log(categoriesEn);
categoriesEn.unshift({ category: 'All', count: frontCount, uri: `${appUrl}/browse`});
let categoriesAr = await categoriesFromCache('Ar');
console.log(categoriesAr);
categoriesAr.unshift({ category: 'الجميع', count: frontCount, uri: `${appUrl}/browse`});

return {
Expand Down

0 comments on commit d4b1d23

Please sign in to comment.