Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 184564 | Differences between
and this patch

Collapse All | Expand All

(-)WEB-INF/src/upload/UsageAnalysis.java (-16 / +113 lines)
Lines 6-16 Link Here
6
import java.io.InputStream;
6
import java.io.InputStream;
7
import java.io.PrintStream;
7
import java.io.PrintStream;
8
import java.io.PrintWriter;
8
import java.io.PrintWriter;
9
import java.text.DateFormat;
10
import java.text.SimpleDateFormat;
9
import java.util.ArrayList;
11
import java.util.ArrayList;
12
import java.util.Calendar;
10
import java.util.Collections;
13
import java.util.Collections;
14
import java.util.Date;
11
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.Iterator;
12
import java.util.List;
17
import java.util.List;
13
import java.util.Map;
18
import java.util.Map;
19
import java.util.StringTokenizer;
14
import java.util.zip.ZipEntry;
20
import java.util.zip.ZipEntry;
15
import java.util.zip.ZipFile;
21
import java.util.zip.ZipFile;
16
22
Lines 21-43 Link Here
21
	Map<Integer, Integer> usersNumSelections = new HashMap<Integer, Integer>();
27
	Map<Integer, Integer> usersNumSelections = new HashMap<Integer, Integer>();
22
28
23
	Map<String, Integer> totalNumSelections = new HashMap<String, Integer>();
29
	Map<String, Integer> totalNumSelections = new HashMap<String, Integer>();
24
	
30
31
	Map<String, Integer> totalNumCommands = new HashMap<String, Integer>();
32
25
	final static String USAGE_DIRECTORY = MylarUsageUploadServlet.UPLOAD_DIRECTORY;
33
	final static String USAGE_DIRECTORY = MylarUsageUploadServlet.UPLOAD_DIRECTORY;
26
	
34
27
	final static String LOGGING_DIRECTORY = "home//study//logging//";
35
	final static String LOGGING_DIRECTORY = "home//study//logging//";
28
		
36
29
	final static String ERROR_LOGGING_FILE = "MylarUsageAnalysisErrorLog.txt";
37
	final static String ERROR_LOGGING_FILE = "MylarUsageAnalysisErrorLog.txt";
30
38
31
	final static String USAGE_SUMMARY_FILE = "usageSummary.txt";
39
	final static String USAGE_SUMMARY_FILE = "usageSummary.txt";
32
40
33
	int MAX_NUM_VIEWS_TO_REPORT = 10;
41
	int MAX_NUM_VIEWS_TO_REPORT = 10;
34
42
43
	int MAX_NUM_COMMANDS_TO_REPORT = 25;
44
35
	int totalSelections = 0;
45
	int totalSelections = 0;
36
46
37
	public static void main(String []args) {
47
	int totalCommands = 0;
48
49
	public static void main(String[] args) {
38
		UsageAnalysis ua = new UsageAnalysis();
50
		UsageAnalysis ua = new UsageAnalysis();
39
		ua.analyzeLogs();
51
		ua.analyzeLogs();
40
	}
52
	}
53
41
	public void analyzeLogs() {
54
	public void analyzeLogs() {
42
55
43
		try {
56
		try {
Lines 50-55 Link Here
50
				userID = this.getUserId(currFile);
63
				userID = this.getUserId(currFile);
51
64
52
				int numSelections = 0;
65
				int numSelections = 0;
66
				int numCommands = 0;
53
				if (usersNumSelections.containsKey(userID)) {
67
				if (usersNumSelections.containsKey(userID)) {
54
					numSelections = usersNumSelections.get(userID);
68
					numSelections = usersNumSelections.get(userID);
55
				}
69
				}
Lines 70-76 Link Here
70
				String endTag = "</originId>";
84
				String endTag = "</originId>";
71
85
72
				String kindTag = "<kind>";
86
				String kindTag = "<kind>";
73
				String matchKind = "selection";
87
				String selectionKind = "selection";
88
				String commandKind = "command";
74
89
75
				// they should all be zip files, ignore anything that's not
90
				// they should all be zip files, ignore anything that's not
76
				if (currFile.getName().endsWith(".zip")) {
91
				if (currFile.getName().endsWith(".zip")) {
Lines 90-96 Link Here
90
								int kindIndex = buf.indexOf(kindTag);
105
								int kindIndex = buf.indexOf(kindTag);
91
								kindIndex += kindTag.length();
106
								kindIndex += kindTag.length();
92
107
93
								if (buf.substring(kindIndex, kindIndex + matchKind.length()).equals(matchKind)) {
108
								String currKind = buf.substring(kindIndex, kindIndex + selectionKind.length());
109
110
								if (currKind.contains(selectionKind)) {
94
111
95
									numSelections++;
112
									numSelections++;
96
									totalSelections++;
113
									totalSelections++;
Lines 109-114 Link Here
109
									int totalNumViews = totalNumSelections.get(currOriginId) + 1;
126
									int totalNumViews = totalNumSelections.get(currOriginId) + 1;
110
									totalNumSelections.put(currOriginId, totalNumViews);
127
									totalNumSelections.put(currOriginId, totalNumViews);
111
128
129
								} else if (currKind.contains(commandKind)) {
130
									numCommands++;
131
									totalCommands++;
132
									currOriginId = buf.substring(index, endIndex);
133
134
									if (!totalNumCommands.containsKey(currOriginId)) {
135
										totalNumCommands.put(currOriginId, 0);
136
									}
137
138
									int currNumCommands = totalNumCommands.get(currOriginId) + 1;
139
									totalNumCommands.put(currOriginId, currNumCommands);
112
								}
140
								}
113
141
114
								buf = buf.substring(endIndex + endTag.length(), buf.length());
142
								buf = buf.substring(endIndex + endTag.length(), buf.length());
Lines 214-242 Link Here
214
242
215
			PrintStream summaryLogStream = new PrintStream(new FileOutputStream(summaryFile, true));
243
			PrintStream summaryLogStream = new PrintStream(new FileOutputStream(summaryFile, true));
216
244
217
			summaryLogStream.println("Total events: " + totalSelections);
245
			summaryLogStream.println("<h2>Mylar Community Usage Statistics</h2>");
218
			summaryLogStream.println("Number of unique users: " + userToViewMap.entrySet().size());
246
			summaryLogStream.println("These statistics are updated once per day.  They were last updated at "
219
			summaryLogStream.println();
247
					+ DateFormat.getTimeInstance(DateFormat.DEFAULT).format(Calendar.getInstance().getTime()) + " "
248
					+ new SimpleDateFormat("z").format(Calendar.getInstance().getTime()) + " on "
249
					+ DateFormat.getDateInstance().format(Calendar.getInstance().getTime()) + ".");
250
			summaryLogStream.println("<br><br>");
251
252
			summaryLogStream.println("<b>Total events: " + (totalSelections + totalCommands) + "</b><br>");
253
			summaryLogStream.println("<b>Number of unique users: " + userToViewMap.entrySet().size() + "</b><br><br>");
254
			summaryLogStream.println("");
255
256
			summaryLogStream.println("<b>" + " " + MAX_NUM_VIEWS_TO_REPORT + " most used views: </b>");
220
257
221
			summaryLogStream.println(MAX_NUM_VIEWS_TO_REPORT + " most used views:");
258
			summaryLogStream.println("<table border=1 rules=rows|columns cellpadding=4>");
222
259
223
			List<String> viewUsage = new ArrayList<String>();
260
			List<String> viewUsage = new ArrayList<String>();
224
			for (String view : totalNumSelections.keySet()) {
261
			for (String view : totalNumSelections.keySet()) {
225
				float numSelections = (float) (totalNumSelections.get(view));
262
				float numSelections = (float) (totalNumSelections.get(view));
226
				float viewUse = numSelections / totalSelections;
263
				float viewUse = numSelections / totalSelections;
227
				String formattedViewUse = formatAsPercentage(viewUse);
264
				String formattedViewUse = formatAsPercentage(viewUse);
228
				viewUsage.add(formattedViewUse + ": " + view + " (" + totalNumSelections.get(view) + ")");
265
				viewUsage.add(formattedViewUse + "," + view + "," + totalNumSelections.get(view));
229
			}
266
			}
230
			Collections.sort(viewUsage, new PercentUsageComparator());
267
			Collections.sort(viewUsage, new PercentUsageComparator());
231
			int numViewsToReport = 0;
268
			int numViewsToReport = 0;
232
			for (String viewUsageSummary : viewUsage) {
269
			Iterator<String> listIterator = viewUsage.iterator();
233
				if (MAX_NUM_VIEWS_TO_REPORT == -1 || numViewsToReport < MAX_NUM_VIEWS_TO_REPORT) {
270
			while (listIterator.hasNext()
271
					&& (MAX_NUM_VIEWS_TO_REPORT == -1 || numViewsToReport < MAX_NUM_VIEWS_TO_REPORT)) {
234
272
235
					summaryLogStream.println(viewUsageSummary);
273
				String[] nextRow = listIterator.next().split(",");
236
					numViewsToReport++;
274
237
				}
275
				summaryLogStream.println("<tr>");
276
277
				summaryLogStream.println("<td>");
278
				summaryLogStream.println(nextRow[0]);
279
				summaryLogStream.println("</td>");
280
281
				summaryLogStream.println("<td>");
282
				summaryLogStream.println(nextRow[1]);
283
				summaryLogStream.println("</td>");
284
285
				summaryLogStream.println("<td>");
286
				summaryLogStream.println(nextRow[2]);
287
				summaryLogStream.println("</td>");
288
289
				summaryLogStream.println("</tr>");
290
				numViewsToReport++;
291
			}
292
293
			summaryLogStream.println("</table>");
294
			summaryLogStream.println("<br><br>");
295
296
			summaryLogStream.println("<b>" + " " + MAX_NUM_COMMANDS_TO_REPORT + " most used commands: </b>");
297
298
			//Commands
299
			summaryLogStream.println("<table border=1 rules=rows|columns cellpadding=4>");
300
301
			List<String> commandUsage = new ArrayList<String>();
302
			for (String cmd : totalNumCommands.keySet()) {
303
				float numCommands = (float) (totalNumCommands.get(cmd));
304
				float commandUse = numCommands / totalCommands;
305
				String formattedCmdUse = formatAsPercentage(commandUse);
306
				commandUsage.add(formattedCmdUse + "," + cmd + "," + totalNumCommands.get(cmd));
307
			}
308
			Collections.sort(commandUsage, new PercentUsageComparator());
309
			int numCommandsToReport = 0;
310
311
			Iterator<String> cmdListIterator = commandUsage.iterator();
312
			while (cmdListIterator.hasNext()
313
					&& (MAX_NUM_COMMANDS_TO_REPORT == -1 || numCommandsToReport < MAX_NUM_COMMANDS_TO_REPORT)) {
314
315
				String[] nextRow = cmdListIterator.next().split(",");
316
317
				summaryLogStream.println("<tr>");
318
319
				summaryLogStream.println("<td>");
320
				summaryLogStream.println(nextRow[0]);
321
				summaryLogStream.println("</td>");
322
323
				summaryLogStream.println("<td>");
324
				summaryLogStream.println(nextRow[1]);
325
				summaryLogStream.println("</td>");
326
327
				summaryLogStream.println("<td>");
328
				summaryLogStream.println(nextRow[2]);
329
				summaryLogStream.println("</td>");
330
331
				summaryLogStream.println("</tr>");
332
				numCommandsToReport++;
238
			}
333
			}
239
334
335
			summaryLogStream.println("</table>");
336
			summaryLogStream.close();
240
		} catch (IOException e) {
337
		} catch (IOException e) {
241
			logError(e.getMessage());
338
			logError(e.getMessage());
242
		}
339
		}
(-).refactorings/2007/5/19/refactorings.history (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<session version="1.0">
3
<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original project: 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original element: 'upload.InteractionEventSummarySorter.java'" description="Delete element" element1="/WEB-INF\/src&lt;upload{InteractionEventSummarySorter.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1178657596406" subPackages="false" version="1.0"/>
4
<refactoring comment="Rename local variable 'matchKind' in 'upload.UsageAnalysis.analyzeLogs()' to 'selectionKind'&#13;&#10;- Original project: 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original element: 'upload.UsageAnalysis.analyzeLogs().matchKind'&#13;&#10;- Renamed element: 'upload.UsageAnalysis.analyzeLogs().selectionKind'&#13;&#10;- Update references to refactored element" description="Rename local variable 'matchKind'" id="org.eclipse.jdt.ui.rename.local.variable" input="/WEB-INF\/src&lt;upload{UsageAnalysis.java" name="selectionKind" references="true" selection="2266 9" stamp="1178748252765" version="1.0"/>
5
<refactoring accessors="true" comment="Delete 5 element(s) from project 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original project: 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original elements:&#13;&#10;     upload.CommandUsageCollector.java&#13;&#10;     upload.InteractionByTypeSummary.java&#13;&#10;     upload.InteractionEvent.java&#13;&#10;     upload.InteractionEventSummary.java&#13;&#10;     upload.InteractionEventUtil.java" description="Delete elements" element1="/WEB-INF\/src&lt;upload{CommandUsageCollector.java" element2="/WEB-INF\/src&lt;upload{InteractionEventUtil.java" element3="/WEB-INF\/src&lt;upload{InteractionEventSummary.java" element4="/WEB-INF\/src&lt;upload{InteractionByTypeSummary.java" element5="/WEB-INF\/src&lt;upload{InteractionEvent.java" elements="5" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1178827320640" subPackages="false" version="1.0"/>
6
<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original project: 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original element: 'upload.IUsageCollector.java'" description="Delete element" element1="/WEB-INF\/src&lt;upload{IUsageCollector.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1178827326515" subPackages="false" version="1.0"/>
7
</session>
(-).refactorings/2007/4/17/refactorings.history (+5 lines)
Added Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<session version="1.0">
3
<refactoring comment="Move 1 elements(s) to 'lib'&#13;&#10;- Original project: 'org.eclipse.mylar.monitor.server'&#13;&#10;- Destination element: 'lib'&#13;&#10;- Original element: 'commons-fileupload-1.2.jar'" description="Move file" element1="WEB-INF/lib/lib/commons-fileupload-1.2.jar" files="1" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1177699968406" target="/org.eclipse.mylar.monitor.server/WEB-INF/lib" units="0" version="1.0"/>
4
<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original project: 'org.eclipse.mylar.monitor.server'&#13;&#10;- Original element: 'lib'" description="Delete element" element1="WEB-INF/lib/lib" elements="0" flags="589830" id="org.eclipse.jdt.ui.delete" resources="1" stamp="1177699973515" subPackages="false" version="1.0"/>
5
</session>
(-).refactorings/2007/5/19/refactorings.index (+4 lines)
Added Link Here
1
1178657596406	Delete element
2
1178748252765	Rename local variable 'matchKind'
3
1178827320640	Delete elements
4
1178827326515	Delete element
(-).refactorings/2007/4/17/refactorings.index (+2 lines)
Added Link Here
1
1177699968406	Move file
2
1177699973515	Delete element

Return to bug 184564