Subversion Repositories SmartDukaan

Rev

Rev 21297 | Rev 21389 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21297 Rev 21308
Line 99... Line 99...
99
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), ProfitMandiConstants.URL_SOLR_SUGGESTION , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS,solrSearchResultResponse);
99
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), ProfitMandiConstants.URL_SOLR_SUGGESTION , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS,solrSearchResultResponse);
100
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
100
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
101
	}
101
	}
102
 
102
 
103
	private JsonArray sanatizedResults(){
103
	private JsonArray sanatizedResults(){
104
 
-
 
105
		//Need to re-write this section.This sucks badly
104
		//Need to re-write this section.This sucks badly
106
 
-
 
107
		JsonArray output = Json.array().asArray();
105
		JsonArray output = Json.array().asArray();
108
		JsonArray temp_mobiles = getResults(3);
106
		JsonArray temp_mobiles = getResults(3);
109
		logger.info("Temp mobiles "+temp_mobiles.toString());
-
 
110
		JsonArray temp_tablets = getResults(5);
107
		JsonArray temp_tablets = getResults(5);
111
		logger.info("Temp tablets "+temp_tablets.toString());
-
 
112
		JsonArray temp_accesories = getResults(6);
108
		JsonArray temp_accesories = getResults(6);
113
		logger.info("Temp accessories "+temp_accesories.toString());
-
 
114
 
-
 
115
		if (max_accessory_score > max_mobile_score){
109
		if (max_accessory_score > max_mobile_score){
116
			for (JsonValue j : temp_accesories){
110
			for (JsonValue j : temp_accesories){
117
				output.add(j);
111
				output.add(j);
118
			}
112
			}
119
		}
113
		}
120
 
-
 
121
		int toFetch = temp_accesories.size() == 0 ? 5 : 3;
114
		int toFetch = temp_accesories.size() == 0 ? 5 : 3;
122
		int count = 1;
115
		int count = 1;
123
 
-
 
124
		if (max_mobile_score > max_tablet_score){
116
		if (max_mobile_score > max_tablet_score){
125
 
-
 
126
			for (JsonValue j : temp_mobiles){
117
			for (JsonValue j : temp_mobiles){
127
				if (count > toFetch)
118
				if (count > toFetch)
128
					break;
119
					break;
129
				output.add(j);
120
				output.add(j);
130
				count++;
121
				count++;
131
			}
122
			}
132
 
-
 
133
			count = 1;
123
			count = 1;
134
 
-
 
135
			for (JsonValue j : temp_tablets){
124
			for (JsonValue j : temp_tablets){
136
				if (count > toFetch)
125
				if (count > toFetch)
137
					break;
126
					break;
138
				output.add(j);
127
				output.add(j);
139
				count++;
128
				count++;
140
			}
129
			}
141
		}
130
		}
142
 
-
 
143
		else{
131
		else{
144
			for (JsonValue j : temp_tablets){
132
			for (JsonValue j : temp_tablets){
145
				if (count > toFetch)
133
				if (count > toFetch)
146
					break;
134
					break;
147
				output.add(j);
135
				output.add(j);
148
				count++;
136
				count++;
149
			}
137
			}
150
 
-
 
151
			count = 1;
138
			count = 1;
152
 
-
 
153
			for (JsonValue j : temp_mobiles){
139
			for (JsonValue j : temp_mobiles){
154
				if (count > toFetch)
140
				if (count > toFetch)
155
					break;
141
					break;
156
				output.add(j);
142
				output.add(j);
157
				count++;
143
				count++;
158
			}
144
			}
159
		}
145
		}
160
 
-
 
161
		if (max_accessory_score <= max_mobile_score){
146
		if (max_accessory_score <= max_mobile_score){
162
			for (JsonValue j : temp_accesories){
147
			for (JsonValue j : temp_accesories){
163
				output.add(j);
148
				output.add(j);
164
			}
149
			}
165
		}
150
		}
166
 
-
 
167
		logger.info("====================================");
-
 
168
		logger.info("Final output "+output);
-
 
169
 
-
 
170
		return output;
151
		return output;
171
	}
152
	}
172
 
153
 
173
	private JsonArray getResults(int category_id){
154
	private JsonArray getResults(int category_id){
174
 
155