Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
fixed reportType not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
max-wittig committed Jan 17, 2017
1 parent 20ab54a commit 1580ba3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
23 changes: 11 additions & 12 deletions src/com/maxwittig/reportgenerator/builder/HTMLReportBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,34 @@ class HTMLReportBuilder(timekeeperTasks : ArrayList<TimekeeperTask>, val reportT

private fun addMonthlyHTML(body : Html)
{
addHTML(monthlyTasks, body, taskString = "Your 10 longest tasks this month")
addHTML(monthlyTasks, body, reportType, taskString = "Your 10 longest tasks this month")
}

private fun addWeeklyHTML(body : Html)
{
addHTML(weeklyTasks, body, taskString = "Longest weekly tasks per day", format = SimpleDateFormat("EEEE dd.MM.yyyy - HH:mm:ss"))
addHTML(weeklyTasks, body, reportType, format = SimpleDateFormat("EEEE dd.MM.yyyy - HH:mm:ss"))
}

private fun addTodayHTML(body : Html)
{
addHTML(todayTasks, body, taskString = "Daily Tasks")
addHTML(todayTasks, body, ReportType.DAILY)
}

/**
* called by every reportType. Adds taskTable and projectTable to Body
*/
private fun addHTML(tasks: ArrayList<TimekeeperTask>, body: Html,
taskString : String = reportType.reportTypeName + " tasks",
projectString: String = reportType.reportTypeName + " projects",
private fun addHTML(tasks: ArrayList<TimekeeperTask>, body: Html, currentReportType: ReportType,
taskString : String = currentReportType.reportTypeName + " tasks",
format: SimpleDateFormat = SimpleDateFormat("dd.MM.yyyy - HH:mm:ss"))
{
body.h3().text(taskString)
addTaskTable(tasks, body, format)
body.br().end()
body.h3().text(projectString)
addProjectTable(body, getProjectTimeHashMap(tasks))
body.h3().text(currentReportType.reportTypeName + " projects")
addProjectTable(body, getProjectTimeHashMap(tasks), currentReportType)
}

private fun addProjectTable(htmlElement: Html, hashMap: Map<String,Long>)
private fun addProjectTable(htmlElement: Html, hashMap: Map<String,Long>, currentReportType: ReportType)
{
val table = htmlElement.table()
addTableHead(table, arrayOf("ProjectName", "TotalTime"))
Expand All @@ -106,17 +105,17 @@ class HTMLReportBuilder(timekeeperTasks : ArrayList<TimekeeperTask>, val reportT
val todayTimeRow = tBody.tr()
todayTimeRow.td().text("Total Time").end()

if(reportType == ReportType.MONTHLY)
if(currentReportType == ReportType.MONTHLY)
{
todayTimeRow.td().text(getTotalTimeOfTasksMonthly()).end()
}
else
if(reportType == ReportType.WEEKLY)
if(currentReportType == ReportType.WEEKLY)
{
todayTimeRow.td().text(getTotalTimeOfTasksWeekly()).end()
}
else
if(reportType == ReportType.DAILY)
if(currentReportType == ReportType.DAILY)
{
todayTimeRow.td().text(getTotalTimeOfTasksToday()).end()
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxwittig/reportgenerator/builder/ReportBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ abstract class ReportBuilder(private val timekeeperTasks : ArrayList<TimekeeperT

private fun getParsedMonthlyTasks() : ArrayList<TimekeeperTask>
{
var tasks = ArrayList<TimekeeperTask>()
val tasks = ArrayList<TimekeeperTask>()
for(task in timekeeperTasks)
{
if(isSameMonth(todaysDate, task.startTime))
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxwittig/reportgenerator/main/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun main(args: Array<String>)
val settings = parser.getSettings()
val mailSender = MailHandler(settings)
val timekeeperParser = TimekeeperParser(timekeeperFile)
val reportType = ReportType.getCurrentReportType(settings.weeklyReportEnabled, settings.monthlyReportEnabled)
val reportType = ReportType.MONTHLY //ReportType.getCurrentReportType(settings.weeklyReportEnabled, settings.monthlyReportEnabled)
if (mailType == MailType.PLAIN)
{
val reportBuilder = PlainTextReportBuilder(timekeeperParser.getTasks(), reportType)
Expand Down

0 comments on commit 1580ba3

Please sign in to comment.