Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sample input :- array of report id [id1,id2,id3]
- sample output :- array
- {
- id1:"reportid",
- reportdetail:"reportdetails",
- evidences :[e1,
- e2,
- . .
- ]
- feedback :[f1,f2,f3..]
- }
- reportArray.forEach(function(singleReport) {
- this part of code is not executing because report array is coming empty always.calling this after for loops ends but because of callbacks the value is still not persist here.
- });
- enter code here
- // Get Existing Reports Stored Procedure
- function sproc_GetReportsForQueue_Copy(reportObject) {
- reportObject = [{
- state: "AvailableForT1",
- reportId: '295398e7-f468-a541-9d12-70dff0809da3',
- id: 20055
- },
- {
- state: "AvailableForT1",
- reportId: '00e4a1dc-0b4e-7465-901a-5eaebd50fb41',
- id: 20055
- }
- ]
- if (!reportObject || !reportObject.length) {
- throw "Input parameters are not supplied.";
- }
- //Initialization
- var collection = getContext().getCollection();
- var collectionLink = collection.getSelfLink();
- var response = getContext().getResponse();
- var reportArray = [];
- var mainArray = new Array();
- var feedbackArray = new Array();
- var evidenceArray = new Array();
- for (var i = 0; i < reportObject.length; i++) {
- //Gets the state and report id
- var state = reportObject[i].state;
- var reportId = reportObject[i].reportId;
- var reportQuery = "SELECT r.id as reportId,r.routingTargetType as routingTargetType,r.createdTimestamp AS createdTimeStamp from r WHERE r.docType='Report' AND r.id ='" + reportId + "' AND ARRAY_CONTAINS(r.reportState,{state: '" + state + "',isCurrent:true},true)";
- var evidenceQuery = "SELECT e.reportId as reportId,e.id As evidenceid,{ moderatorId: e.moderatorNotes.moderatorId, comment: e.moderatorNotes.comment,timeStamp:e.moderatorNotes.timestamp } AS comments,udf.GetEvidenceInfo(e.evidenceDetails) AS evidenceDetail FROM e WHERE e.docType='Evidence' AND e.reportId ='" + reportId + "'";
- var feedbackQuery = "SELECT f.reportId as reportId,f.targetGamertag,f.textReason from f WHERE f.reportId ='" + reportId + "' and f.docType='Feedback'";
- //Gets the report
- var isReportExists = collection.queryDocuments(collection.getSelfLink(), reportQuery,
- function(err, documents, options) {
- if (err) {
- throw err;
- }
- if (!documents || !documents.length) {
- }
- if (documents.length > 0) {
- reportArray.push(documents);
- }
- }
- );
- if (!isReportExists) {
- throw "Unable to fetch the reports from the DB";
- }
- //Gets the Evidence
- var isGetEvidence = collection.queryDocuments(
- collection.getSelfLink(), evidenceQuery,
- function(err, Evidences, options) {
- if (err) {
- throw err;
- }
- if (!Evidences || !Evidences.length) {
- } else {
- evidenceArray.push(Evidences);
- }
- }
- );
- if (!isGetEvidence) {
- }
- var isGetFeedback = collection.queryDocuments(
- collection.getSelfLink(), feedbackQuery,
- function(err, Feedbacks, options) {
- if (err) {
- throw err;
- }
- if (!Feedbacks || !Feedbacks.length) {} else {
- feedbackArray.push({
- Feedback: Feedbacks
- });
- }
- }
- );
- }
- reportArray.forEach(function(singleReport) {
- });
- response.setBody();
- }
Add Comment
Please, Sign In to add comment