summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-12-19 17:46:19 +0000
committerMatthew Lemon <y@yulqen.org>2024-12-19 17:46:19 +0000
commit9f7a724a07b170e72760a9d9ea47e6ddae69f649 (patch)
tree9740964206c9250a78054e5bdaa66637b3f4763b
parent82ba7ed82e7c4568d317ce57906f7c6170e10edc (diff)
Can add meeting
-rw-r--r--tjp.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/tjp.go b/tjp.go
index c044338..bd6c69c 100644
--- a/tjp.go
+++ b/tjp.go
@@ -41,6 +41,18 @@ func init() {
}
}
+// addMODMeeting adds a MOD meeting to the database
+func addMODMeeting(name string, date string, subject string) {
+ var meetingId int
+ query := fmt.Sprintf("INSERT INTO meetings (name, date, subject) VALUES ('%s', '%s', '%s') RETURNING id", name, date, subject)
+ err := db.QueryRow(query).Scan(&meetingId)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("MOD meeting added with ID: %d\n", meetingId)
+}
+
+// addMODContact adds a MOD contact to the database
func addMODContact(firstName, lastName string) {
var contactId int
query := `INSERT INTO contacts (first_name, last_name, contact_type) VALUES ($1, $2, 3) RETURNING id`
@@ -51,6 +63,7 @@ func addMODContact(firstName, lastName string) {
fmt.Printf("MOD contact added with ID: %d\n", contactId)
}
+// addSleepEntry adds a sleep entry to the database
func addSleepEntry(entry string, journalType int) {
_, err := db.Exec("INSERT INTO journal_entries (entry, type) VALUES ('%s', %d)", entry, journalType)
if err != nil {
@@ -58,6 +71,7 @@ func addSleepEntry(entry string, journalType int) {
}
}
+// addJournalEntry adds a journal entry to the database
func addJournalEntry(entry string, journalType int) {
_, err := db.Exec(fmt.Sprintf("INSERT INTO journal_entries (entry, type) VALUES ('%s', %d)", entry, journalType))
if err != nil {
@@ -177,8 +191,12 @@ func main() {
entry := flag.String("entry", "", "Content of the journal entry")
+ dateOfEntry := flag.String("date", "", "Date of entry")
+
orientationFlag := flag.String("orientation", "horizontal", "Orientation of the journal entries (vertical or horizontal)")
+ addMODMeetingFlag := flag.Bool("add-meeting", false, "Add a MOD meeting")
+
addMODEntryFlag := flag.Bool("add-mod", false, "Add a MOD entry")
addPersonalEntryFlag := flag.Bool("add-personal", false, "Add a Personal entry")
addJobbylogEntryFlag := flag.Bool("add-jobby", false, "Add a Jobbylog entry")
@@ -198,6 +216,14 @@ func main() {
log.Fatal("Both firstName and lastName must be provided for adding a MOD contact")
}
addMODContact(*firstName, *lastName)
+ } else if *addMODMeetingFlag {
+ if *entry == "" {
+ log.Fatal("Meeting name must be provided with -entry flag")
+ }
+ if *dateOfEntry == "" {
+ log.Fatal("Meeting date must be provided with -date flag")
+ }
+ addMODMeeting(*entry, *dateOfEntry, "Meeting")
} else if *addSleepEntryFlag {
if *entry == "" {
log.Fatal("Sleep entry content must be provided")