Search in sources :

Example 1 with DigestsPanel

use of com.gitblit.wicket.panels.DigestsPanel in project gitblit by gitblit.

the class DashboardPage method addActivity.

protected void addActivity(UserModel user, Collection<RepositoryModel> repositories, String feedTitle, int daysBack) {
    Calendar c = Calendar.getInstance();
    c.add(Calendar.DATE, -1 * daysBack);
    Date minimumDate = c.getTime();
    TimeZone timezone = getTimeZone();
    // create daily commit digest feed
    List<DailyLogEntry> digests = new ArrayList<DailyLogEntry>();
    for (RepositoryModel model : repositories) {
        if (model.isCollectingGarbage) {
            continue;
        }
        if (model.hasCommits && model.lastChange.after(minimumDate)) {
            Repository repository = app().repositories().getRepository(model.name);
            List<DailyLogEntry> entries = RefLogUtils.getDailyLogByRef(model.name, repository, minimumDate, timezone);
            digests.addAll(entries);
            repository.close();
        }
    }
    Fragment activityFragment = new Fragment("activity", "activityFragment", this);
    add(activityFragment);
    activityFragment.add(new Label("feedTitle", feedTitle));
    if (digests.size() == 0) {
        // quiet or no starred repositories
        if (repositories.size() == 0) {
            if (UserModel.ANONYMOUS.equals(user)) {
                if (daysBack == 1) {
                    activityFragment.add(new Label("digests", getString("gb.noActivityToday")));
                } else {
                    activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
                }
            } else {
                activityFragment.add(new LinkPanel("digests", null, getString("gb.findSomeRepositories"), RepositoriesPage.class));
            }
        } else {
            if (daysBack == 1) {
                activityFragment.add(new Label("digests", getString("gb.noActivityToday")));
            } else {
                activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
            }
        }
    } else {
        // show daily commit digest feed
        Collections.sort(digests);
        DigestsPanel digestsPanel = new DigestsPanel("digests", digests);
        activityFragment.add(digestsPanel);
    }
    // add the nifty charts
    if (!ArrayUtils.isEmpty(digests)) {
        // aggregate author exclusions
        Set<String> authorExclusions = new TreeSet<String>();
        for (String author : app().settings().getStrings(Keys.web.metricAuthorExclusions)) {
            authorExclusions.add(author.toLowerCase());
        }
        for (RepositoryModel model : repositories) {
            if (!ArrayUtils.isEmpty(model.metricAuthorExclusions)) {
                for (String author : model.metricAuthorExclusions) {
                    authorExclusions.add(author.toLowerCase());
                }
            }
        }
        addCharts(activityFragment, digests, authorExclusions, daysBack);
    } else {
        activityFragment.add(new Label("charts").setVisible(false));
        activityFragment.add(new Label("feedheader").setVisible(false));
    }
}
Also used : DigestsPanel(com.gitblit.wicket.panels.DigestsPanel) Calendar(java.util.Calendar) DailyLogEntry(com.gitblit.models.DailyLogEntry) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) RepositoryModel(com.gitblit.models.RepositoryModel) Fragment(org.apache.wicket.markup.html.panel.Fragment) Date(java.util.Date) LinkPanel(com.gitblit.wicket.panels.LinkPanel) TimeZone(java.util.TimeZone) Repository(org.eclipse.jgit.lib.Repository) TreeSet(java.util.TreeSet)

Aggregations

DailyLogEntry (com.gitblit.models.DailyLogEntry)1 RepositoryModel (com.gitblit.models.RepositoryModel)1 DigestsPanel (com.gitblit.wicket.panels.DigestsPanel)1 LinkPanel (com.gitblit.wicket.panels.LinkPanel)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 TimeZone (java.util.TimeZone)1 TreeSet (java.util.TreeSet)1 Label (org.apache.wicket.markup.html.basic.Label)1 Fragment (org.apache.wicket.markup.html.panel.Fragment)1 Repository (org.eclipse.jgit.lib.Repository)1