Subversion Repositories SmartDukaan

Rev

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

Rev 2799 Rev 3516
Line 6... Line 6...
6
import java.io.BufferedReader;
6
import java.io.BufferedReader;
7
import java.io.InputStreamReader;
7
import java.io.InputStreamReader;
8
import java.io.Serializable;
8
import java.io.Serializable;
9
import java.net.URL;
9
import java.net.URL;
10
import java.net.URLConnection;
10
import java.net.URLConnection;
-
 
11
import java.util.Calendar;
11
import java.util.Comparator;
12
import java.util.Comparator;
12
import java.util.HashMap;
13
import java.util.HashMap;
13
import java.util.LinkedHashMap;
14
import java.util.LinkedHashMap;
14
import java.util.Map;
15
import java.util.Map;
15
import java.util.Map.Entry;
16
import java.util.Map.Entry;
Line 36... Line 37...
36
	    }
37
	    }
37
	  }
38
	  }
38
	}
39
	}
39
 
40
 
40
	
41
	
41
	public void fetchAndStoreComparisonStats(long fromDate, long toDate){
42
	public void fetchAndStoreComparisonStats(){
42
		String requestParameters = "fromdate=" +  fromDate + "&todate=" + toDate;
-
 
43
		String data = ComparisonStatsFetcher.sendGetRequest(GOOGLE_COMPARE_DATA_URL, requestParameters);
43
		String data = ComparisonStatsFetcher.sendGetRequest(GOOGLE_COMPARE_DATA_URL, null);
44
		try {
44
		try {
45
			JSONObject json = new JSONObject(data);
45
			JSONObject json = new JSONObject(data);
46
			Map<Long, Map<Long, Long>> comparisonStats = new HashMap<Long, Map<Long, Long>>();
46
			Map<Long, Map<Long, Long>> comparisonStats = new HashMap<Long, Map<Long, Long>>();
47
			
47
			
48
			for (String itemId : JSONObject.getNames(json)) {
48
			for (String itemId : JSONObject.getNames(json)) {
Line 103... Line 103...
103
		}
103
		}
104
		return mostCompared;
104
		return mostCompared;
105
	}
105
	}
106
	
106
	
107
	public static void main(String[] args) throws Exception{
107
	public static void main(String[] args) throws Exception{
-
 
108
		Calendar cal = Calendar.getInstance();
-
 
109
        //int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
-
 
110
        //if(dayOfWeek == Calendar.SUNDAY){
-
 
111
    		long toDate = cal.getTime().getTime();
-
 
112
    		cal.add(Calendar.MONTH, -1);
-
 
113
    		long fromDate = cal.getTime().getTime();
108
//		String data = FileUtils.readFileToString(new File("/home/rajveer/Desktop/comparisonStats.json"));
114
        	ComparisonStatsFetcher csf = new ComparisonStatsFetcher();
109
//		JSONObject json = new JSONObject(data);
115
        	csf.fetchAndStoreComparisonStats();
110
	}
116
	}
111
	
117
	
112
 
118
 
113
	/**
119
	/**
114
	 * 
120
	 *