Skip to content

Commit

Permalink
restore the general format for exporting notes, info needs, and of co…
Browse files Browse the repository at this point in the history
…urse options!
  • Loading branch information
epugh committed Jan 20, 2024
1 parent f82f41c commit 5c44dbd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/export_case/_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3 class="modal-title">Export Case: <span class="modal-case">{{ ctrl.theCase.ca
<input type="radio" id="general" name="exportSelection" value="general" ng-model="ctrl.options.which">
<label for="general">General</label>
<span class="help-block">
CSV file with <code>Team Name,Case Name,Case ID,Query Text,Score,Date Last Scored,Count,Information Need,Notes</code>
CSV file with <code>Team Name,Case Name,Case ID,Query Text,Score,Date Last Scored,Count,Information Need,Notes,Options</code>
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ angular.module('QuepidApp')

if ( options.which === 'general' ) {
$log.info('Selected "general" as export option.');

// Go back to the API in case other users have updates that we should include.
caseSvc.get(ctrl.theCase.caseNo, false).then(function(acase) {
csv = caseCSVSvc.stringify(acase, true);
csv = caseCSVSvc.stringify(
acase,
queriesSvc.queries,
true
);
blob = new Blob([csv], {
type: 'text/csv'
});
Expand All @@ -61,10 +65,9 @@ angular.module('QuepidApp')
} else if ( options.which === 'detailed' ) {
$log.info('Selected "detailed" as export option.');

var queries = queriesSvc.queries;
csv = caseCSVSvc.stringifyQueriesDetailed(
ctrl.theCase,
queries,
queriesSvc.queries,
true
);
blob = new Blob([csv], {
Expand Down
28 changes: 22 additions & 6 deletions app/assets/javascripts/services/caseCSVSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
'Date Last Scored',
'Count',
'Information Need',
'Notes'
'Notes',
'Options'
];

var headerString = header.join(',');
Expand Down Expand Up @@ -116,7 +117,9 @@
* @param aCase
*
*/
function stringify (aCase, withHeader) {
function stringify (aCase, queries, withHeader) {
// queries is sourced from queriesSvc.queries for query info and
// aCase.lastScore.queries has the scoring info for the queries.
var csvContent = '';

if (withHeader) {
Expand All @@ -134,22 +137,35 @@
var count = data.numFound;

id = parseInt(id,10); // Convert from string

var query = null;
angular.forEach(queries, function (data, queryId) {
if (parseInt(queryId,10) === id){
query = data;
return false;
}
});

var query = aCase.queries.filter(function(q) { return q.queryId === id; })[0];
var notes = query ? query.notes || null : null;
var informationNeed = query ? query.information_need || null : null;
var notes = query.notes || null;
var informationNeed = query.informationNeed || null;
var options = query.options || null;

if (Object.keys(options).length === 0){
options = null; // blank out boiler plate options json.
}

infoArray = [];

infoArray.push(stringifyField(aCase.teamNames()));
infoArray.push(stringifyField(aCase.caseName));
infoArray.push(stringifyField(aCase.lastScore.case_id));
infoArray.push(stringifyField(aCase.caseNo));
infoArray.push(stringifyField(text));
infoArray.push(stringifyField(score));
infoArray.push(stringifyField(aCase.lastScore.updated_at));
infoArray.push(stringifyField(count));
infoArray.push(stringifyField(informationNeed));
infoArray.push(stringifyField(notes));
infoArray.push(stringifyField(options));

dataString = infoArray.join(',');
csvContent += dataString + EOL;
Expand Down

0 comments on commit 5c44dbd

Please sign in to comment.