summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tjp.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/tjp.go b/tjp.go
index 65eee1c..500b80c 100644
--- a/tjp.go
+++ b/tjp.go
@@ -52,6 +52,13 @@ func addMODMeeting(name string, date string, subject string) {
fmt.Printf("MOD meeting added with ID: %d\n", meetingId)
}
+func addMODMeetingJournalEntry(entry string, meetingID int) {
+ _, err := db.Exec(fmt.Sprintf("INSERT INTO journal_entries (entry, type, meeting_id) VALUES ('%s', %d, %d)", entry, JOURNAL_TYPE_MOD, meetingID))
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
// addMODContact adds a MOD contact to the database
func addMODContact(firstName, lastName string) {
var contactId int
@@ -98,6 +105,27 @@ func listMeetings() {
}
}
+func listEntriesForMeeting(meetingID int) {
+ // this should be a join which includes the meeting name
+ rows, err := db.Query(fmt.Sprintf("select journal_entries.id, journal_entries.date_added, journal_entries.entry, meetings.name from journal_entries inner join meetings on journal_entries.meeting_id = meetings.id where journal_entries.meeting_id = %d order by journal_entries.date_added asc, journal_entries.id asc", meetingID))
+
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer rows.Close()
+ fmt.Println(fmt.Sprintf("Entries for meeting ID: %d", meetingID))
+ for rows.Next() {
+ var id int
+ var date time.Time
+ var entry string
+ var meetingName string
+ if err := rows.Scan(&id, &date, &entry, &meetingName); err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("%d\t %s\t %s\t %s\n", id, meetingName, date.Format("2006-01-02 - 15:04:05"), entry)
+ }
+}
+
// List journal entries, dependent on journalType
func listjournalEntries(orientation string, journalType int) {
var rows *sql.Rows
@@ -220,9 +248,11 @@ func main() {
addPersonalEntryFlag := addCmd.Bool("personal", false, "Add a Personal entry")
addMODEntryFlag := addCmd.Bool("mod", false, "Add a MOD entry")
addMODMeetingFlag := addCmd.Bool("meeting", false, "Add a MOD meeting")
+ addMODMeetingNoteFlag := addCmd.Bool("meeting-note", false, "Add a note to a MOD meeting")
addJobbylogEntryFlag := addCmd.Bool("jobby", false, "Add a Jobbylog entry")
addSleepEntryFlag := addCmd.Bool("sleep", false, "Add a sleep entry")
entry := addCmd.String("entry", "", "Content of the journal entry")
+ meetingID := addCmd.Int("meeting-id", 1, "ID of the meeting to add a note to")
dateOfEntry := addCmd.String("date", "", "Date of entry")
// list command
@@ -230,6 +260,8 @@ func main() {
listPersonalEntriesFlag := listCmd.Bool("personal", false, "List all personal entries")
listMODEntriesFlag := listCmd.Bool("mod", false, "List all MOD entries, not including those associated with a meeting")
listMODMeetingsFlag := listCmd.Bool("meetings", false, "List all MOD meetings")
+ meetingID = listCmd.Int("meeting-id", 1, "ID of the meeting to add a note to")
+ listEntriesForMODMeetingFlag := listCmd.Bool("meeting-entries", false, "List all entries for a MOD meeting")
listJobbylogEntriesFlag := listCmd.Bool("jobby", false, "List all Jobblylog entries")
listSleepEntriesFlag := listCmd.Bool("sleep", false, "List all sleep entries")
orientationFlag := listCmd.String("orientation", "horizontal", "Orientation of the journal entries (vertical or horizontal)")
@@ -267,6 +299,11 @@ func main() {
log.Fatal("Meeting name must be provided with -entry flag")
}
addMODMeeting(*entry, *dateOfEntry, "Default meeting")
+ } else if *addMODMeetingNoteFlag {
+ if *entry == "" {
+ log.Fatal("Meeting note must be provided with -entry flag")
+ }
+ addMODMeetingJournalEntry(*entry, *meetingID)
} else {
addCmd.PrintDefaults()
}
@@ -283,6 +320,8 @@ func main() {
listjournalEntries(*orientationFlag, JOURNAL_TYPE_SLEEP)
} else if *listMODMeetingsFlag {
listMeetings()
+ } else if *listEntriesForMODMeetingFlag {
+ listEntriesForMeeting(*meetingID)
} else {
listCmd.PrintDefaults()
}