Skip to content

Commit

Permalink
Add a license and details in the data collected dire.
Browse files Browse the repository at this point in the history
  • Loading branch information
Atreyu authored and Atreyu committed Sep 7, 2013
1 parent 6044874 commit 1bc3b26
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 50 deletions.
2 changes: 2 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
--MIT Lience --

Copyright (C) 2013 by Franck MICHEL

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
89 changes: 46 additions & 43 deletions src/fm/flickr/api/wrapper/service/FlickrService.java
Original file line number Diff line number Diff line change
Expand Up @@ -802,46 +802,49 @@ private Map<String, Long> findDateInGroupByDicotomy(String groupId, Long searche
// Get the first (morst recent) and last (oldest) photos of the page
NodeList photosList = xmlResp.getElementsByTagName("photo");
int nbPhotos = photosList.getLength();
Element firstphoto = (Element) photosList.item(0);
Element lastphoto = (Element) photosList.item(nbPhotos - 1);

// If the searched date is before the last (oldest) photo, ie.
// if date < date(last photo), then we must look further in the past
if (searchedDate < Long.valueOf(lastphoto.getAttribute("dateadded"))) {
if (page + increment < maxPages)
page += increment;
logger.trace("searchedDate < " + lastphoto.getAttribute("dateadded") + ": going further in the past");
}
if (nbPhotos > 0) {

// If the searched date is between the first (most recent) and the last (oldest) photos of the page, ie.
// older than the first photo and more recent than the last photo, ie.
// if date(last photo) <= searchedDate <= date(first photo), then we have found the right page!
else if (Long.valueOf(lastphoto.getAttribute("dateadded")) <= searchedDate && searchedDate <= Long.valueOf(firstphoto.getAttribute("dateadded"))) {
indexInPage = 0;
while (indexInPage < photosList.getLength()) {
Element photo = (Element) photosList.item((int) indexInPage);
if (searchedDate > Long.valueOf(photo.getAttribute("dateadded")))
break;
indexInPage++;
// When this inner loop is over, we have found the first photo, in the page, that is more recent than startDate
Element firstphoto = (Element) photosList.item(0);
Element lastphoto = (Element) photosList.item(nbPhotos - 1);

// If the searched date is before the last (oldest) photo, ie.
// if date < date(last photo), then we must look further in the past
if (searchedDate < Long.valueOf(lastphoto.getAttribute("dateadded"))) {
if (page + increment < maxPages)
page += increment;
logger.trace("searchedDate < " + lastphoto.getAttribute("dateadded") + ": going further in the past");
}
foundPage = true;
break;
}

// If the searched date is more recent than (after) the first (most recent) photo, ie.
// if searchedDate > date(first photo), then we have to get back a bit to more recent photos
else if (searchedDate > Long.valueOf(firstphoto.getAttribute("dateadded"))) {
if (page == 1) {
// If page == 1, then the searched date is later than last post on the group, so we actually found the date
logger.debug("There was no post later than the searched date");
foundPage = true;
// If the searched date is between the first (most recent) and the last (oldest) photos of the page, ie.
// older than the first photo and more recent than the last photo, ie.
// if date(last photo) <= searchedDate <= date(first photo), then we have found the right page!
else if (Long.valueOf(lastphoto.getAttribute("dateadded")) <= searchedDate && searchedDate <= Long.valueOf(firstphoto.getAttribute("dateadded"))) {
indexInPage = 0;
while (indexInPage < photosList.getLength()) {
Element photo = (Element) photosList.item((int) indexInPage);
if (searchedDate > Long.valueOf(photo.getAttribute("dateadded")))
break;
indexInPage++;
// When this inner loop is over, we have found the first photo, in the page, that is more recent than startDate
}
foundPage = true;
break;
}
if (page - increment > 0)
page -= increment;
logger.debug("searchedDate > " + firstphoto.getAttribute("dateadded") + ": going futur");

// If the searched date is more recent than (after) the first (most recent) photo, ie.
// if searchedDate > date(first photo), then we have to get back a bit to more recent photos
else if (searchedDate > Long.valueOf(firstphoto.getAttribute("dateadded"))) {
if (page == 1) {
// If page == 1, then the searched date is later than last post on the group, so we actually found the date
logger.debug("There was no post later than the searched date");
foundPage = true;
indexInPage = 0;
break;
}
if (page - increment > 0)
page -= increment;
logger.debug("searchedDate > " + firstphoto.getAttribute("dateadded") + ": going futur");
}
}

// Next turn in the dicotomy
Expand Down Expand Up @@ -1007,15 +1010,15 @@ private String getPhotoUrl(Element photoElement, ImageType type) {

String url = "http://farm" + farmId + ".static.flickr.com/" + serverId + "/" + id + "_" + secret;
switch (type) {
case SQUARE:
return url + "_s.jpg";
case THUMBNAIL:
return url + "_t.jpg";
case BIG:
return url + "_b.jpg";
case MEDIUM:
default:
return url + ".jpg";
case SQUARE:
return url + "_s.jpg";
case THUMBNAIL:
return url + "_t.jpg";
case BIG:
return url + "_b.jpg";
case MEDIUM:
default:
return url + ".jpg";
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/fm/flickr/stat/ProcessProbabilityPerWeekDayAndHour.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ private static void loadFileByDay(String date) throws ServiceException {
}

/**
*
* Distribute the data loaded about upload time and number of uploads into 2 tables
* of the same data sumed by date and time slot
* @param ps the output where to print results
* @param dayOfWeek 1=Sunday to 7=Saturday
*/
Expand All @@ -116,8 +119,6 @@ private static void computeStatistics(int dayOfWeek, PrintStream ps) {
Vector<Integer> postTimeDistrib = TimeStat.getPostTimeDistrib();
Vector<Long> uploadDistrib = DailyUploadsStat.getUploadDistribution();

// Print the results cut down by hour of day, from 0h to 23h
// Output format is: YYY-MM-DD HH:MM; nb of explored photos; nb of uploads; % of explored/posted
for (int hour = 0; hour < 24; hour++) {

int curVal = exploredTable.get(dayOfWeek).get(hour);
Expand Down
18 changes: 13 additions & 5 deletions src/fm/flickr/stat/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ Read data between fm.flickr.stat.startdate and fm.flickr.stat.enddate, and compu
"nb of explored photos in a group / total nb of photos uploaded to that group" during the same time slot.
This takes a long time (lots of requests), to be activated cautiously...
- upload: distribution of number of photos posted to Flickr in function of the hour of day
- activity and anyphoto:
- activity about explored photos:
- distribution of number of explored photos in function of the number of groups they are posted to
- distribution of number of explored photos in function of the number of times they were viewed
- distribution of number of explored photos in function of the number of comments they have
- distribution of number of explored photos in function of the number of favs they have
- distribution of number of explored photos in function of the owner's number of photos (data collected starting 15 Nov 2012)
- distribution of number of explored photos in function of the owner's number of contacts (data collected starting 15 Nov 2012)
- activity about any unexplored photos: data collected starting 8 Jan. 2013 => for photos starting at 8 Dec. 2012:
- distribution of number of explored photos in function of the number of groups they are posted to
- distribution of number of explored photos in function of the number of times they were viewed
- distribution of number of explored photos in function of the number of comments they have
- distribution of number of explored photos in function of the number of favs they have
- distribution of number of explored photos in function of the owner's number of photos (starting 15/11/2012)
- distribution of number of explored photos in function of the owner's number of contacts (starting 15/11/2012)
- distribution of number of explored photos in function of the owner's number of photos
- distribution of number of explored photos in function of the owner's number of contacts


ProcessMonthlyStats:
====================
Expand All @@ -39,8 +47,8 @@ by month, for categories group, tag, user, time, user, activity and upload:
- file monthly_distrib_view.csv: distribution of number of explored photos in function of the number of times they were viewed
- file monthly_distrib_comment.csv: distribution of number of explored photos in function of the number of comments they have
- file monthly_distrib_fav.csv: distribution of number of explored photos in function of the number of favs they have
- file monthly_distrib_owners_photo.csv shows the distribution of those users per number of photos that they have (starting 15/11/2012)
- file monthly_distrib_owners_contact.csv shows the distribution of those users per number of contacts that they have (starting 15/11/2012)
- file monthly_distrib_owners_photo.csv shows the distribution of users per number of photos that they have (starting 15/11/2012)
- file monthly_distrib_owners_contact.csv shows the distribution of users per number of contacts that they have (starting 15/11/2012)


ProcessProbabilityPerWeekDayAndHour:
Expand Down

0 comments on commit 1bc3b26

Please sign in to comment.