Added stats at the review end (agir #2892).

This commit is contained in:
Christian P. MOMON 2018-01-22 10:49:07 +01:00
parent 3de3542a5c
commit c2471e50c1
2 changed files with 115 additions and 2 deletions

View File

@ -352,6 +352,9 @@ public class Hebdobot extends PircBot
}
}
sendMessage("% Durée de la revue : " + this.review.getDurationInMinutes() + " minutes");
sendMessage("% Nombre de participants : " + this.review.getParticipants().size());
sendMessage("% " + this.review.getOwner()
+ ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135");
String participants = StringUtils.join(this.review.getParticipants(), " ");

View File

@ -19,6 +19,7 @@
*/
package org.april.hebdobot.model.review;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
@ -46,6 +47,8 @@ public class Review
private final MessageList messages;
private final String owner;
private final UserAliases aliases;
private LocalDateTime startTime;
private LocalDateTime endTime;
/**
* Instantiates a new review.
@ -64,6 +67,9 @@ public class Review
this.owner = owner;
this.aliases = aliases;
this.startTime = LocalDateTime.now();
this.endTime = null;
}
/**
@ -126,6 +132,85 @@ public class Review
return this.currentTopic;
}
public long getDuration()
{
long result;
if (this.endTime == null)
{
result = Duration.between(this.startTime, LocalDateTime.now()).getSeconds();
}
else
{
result = Duration.between(this.startTime, this.endTime).getSeconds();
}
//
return result;
}
/**
* Gets the duration.
*
* @return the duration
*/
public long getDurationInMinutes()
{
long result;
result = getDuration() / 60;
//
return result;
}
/**
* Gets the end time.
*
* @return the end time
*/
public LocalDateTime getEndTime()
{
return this.endTime;
}
/**
* Gets the formatted end time.
*
* @return the formatted end time
*/
public String getFormattedEndTime()
{
String result;
if (this.endTime == null)
{
result = "??h??";
}
else
{
result = this.endTime.format(DateTimeFormatter.ofPattern("kk'h'mm"));
}
//
return result;
}
/**
* Gets the formatted start time.
*
* @return the formatted start time
*/
public String getFormattedStartTime()
{
String result;
result = this.startTime.format(DateTimeFormatter.ofPattern("kk'h'mm"));
//
return result;
}
/**
* Gets the owner.
*
@ -161,6 +246,16 @@ public class Review
return result;
}
/**
* Gets the start time.
*
* @return the start time
*/
public LocalDateTime getStartTime()
{
return this.startTime;
}
/**
* Checks if is empty.
*
@ -208,16 +303,17 @@ public class Review
{
String result;
//
StringBuffer buffer = new StringBuffer();
addLine(buffer, '=');
addCenter(buffer, "Revue de la semaine en cours");
addEmpty(buffer);
addCenter(buffer,
StringUtils.capitalize(LocalDateTime.now().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy").withLocale(Locale.FRENCH))));
addCenter(buffer, StringUtils.capitalize(LocalDateTime.now().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH))));
addLine(buffer, '=');
addEmpty(buffer);
addEmpty(buffer);
//
addLine(buffer, '=');
addEmpty(buffer);
addCenter(buffer, "Participants", '-');
@ -226,6 +322,7 @@ public class Review
addChunk(buffer, "* " + this.aliases.getRealName(participant) + "\n");
}
//
if (!this.individualTopics.isEmpty())
{
for (final String participant : this.participants)
@ -250,6 +347,7 @@ public class Review
}
}
//
if (!this.collectiveTopics.isEmpty())
{
for (final CollectiveTopic topic : this.collectiveTopics)
@ -266,6 +364,7 @@ public class Review
}
}
//
addEmpty(buffer);
addCenter(buffer, "Log IRC brut");
addEmpty(buffer);
@ -274,6 +373,17 @@ public class Review
addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent() + "\n");
}
//
this.endTime = LocalDateTime.now();
addEmpty(buffer);
addCenter(buffer, "Statistiques");
addEmpty(buffer);
addChunk(buffer, "Horaire de début de la revue : " + getFormattedStartTime() + "\n");
addChunk(buffer, "Horaire de fin de la revue : " + getFormattedEndTime() + "\n");
addChunk(buffer, "Durée de la revue : " + getDurationInMinutes() + " minutes\n");
addChunk(buffer, "Nombre de participants : " + this.participants.size() + "\n");
//
result = buffer.toString();
//