Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/task management and label crud routes #29

Merged
merged 33 commits into from
Feb 17, 2024

Conversation

oliviaseds
Copy link
Contributor

Description

Task Management Crud Routes

Task routes

  • Create, delete, update, filter task by __
  • Assign/remove users to/from task, get users assigned to a given task, filter tasks by a given user

Task label routes

  • Create, edit, delete labels
  • Add labels to a task, edit a task's labels

How Has This Been Tested?

Tested with Swagger and locally with unit tests.

Checklist

  • I have performed a self-review of my code
  • I have reached out to another developer to review my code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

Bedrockdude10 and others added 22 commits January 31, 2024 19:08
* Intial card/button

* Basic card and modal

Basic card and modal skeleton

* fixed card and popup to have the requirments

fixed card and popup to have the requirments

* wip for passing medication data into Card component

* trying to get stuff workin

* trying to get comps workin

* stuff

* Final Working Card + Popup

---------

Co-authored-by: AdharshKan42 <[email protected]>
* feat: userContext stuff idk man

* refactor: general all around fixes (removing unused imports, fixing navigation errors)

* refactor: all over the place with this commit, but added swagger docs for file upload

* refactor: make context more general

* refactor: utilize card and popup in the medlist FE
* feat: added hot reloading for backend code
@@ -58,7 +57,7 @@ CREATE TABLE IF NOT EXISTS task (
start_date timestamp,
end_date timestamp,
notes varchar,
repeating BOOLEAN,
repeating BOOLEAN DEFAULT FALSE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet!

@MattCMcCoy
Copy link
Contributor

Very nice so far! Yall are killing it!!

// @success 200 {array} models.Task
// @failure 400 {object} string
// @router /tasks/filtered [get]
func (pg *PgModel) GetFilteredTasks(c *gin.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewcaplan1 Should we make this route return the tasks between the given start and end time?
I think rn its returning the task if it exactly starts and ends at the given time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviaseds (i think your name was beside this one on the notion)

I agree with Matt, are you able to make this a inclusive range of tasks that fall between start and end task. I put a comment in the transactions file where you'd probs just need to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I will look into that

Comment on lines +56 to +65
// Is there a better way to do this when we don't know which fields are being edited?
editedName := data.LabelName
if editedName == "" {
editedName = labelName
}

var label = models.Label{
GroupID: groupIDInt,
LabelName: editedName,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviaseds Does this mean we can only edit the label name if it is empty?? or am i just dumb

Copy link
Contributor Author

@oliviaseds oliviaseds Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewcaplan1 You can edit the label color without editing the label name (so data.LabelName would be an empty string). In that case the "new" label name is the original label name. The if statement was my solution to not knowing whether name is being changed for the query into the database for label color (since the primary key for labels are name, which might change, and group ID, which won't change), but I do not doubt that there is a better way of solving that issue.

// @success 200 {array} models.Task
// @failure 400 {object} string
// @router /tasks/filtered [get]
func (pg *PgModel) GetFilteredTasks(c *gin.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviaseds (i think your name was beside this one on the notion)

I agree with Matt, are you able to make this a inclusive range of tasks that fall between start and end task. I put a comment in the transactions file where you'd probs just need to change.

Comment on lines 21 to 33
field_names := []string{"group_id", "created_by", "task_status", "task_type", "start_date", "end_date"}
var query string
var args []interface{}

for i, field := range query_fields {
if field != "" {
if query != "" {
query += " AND "
}
query += fmt.Sprintf("%s = $%d", field_names[i], len(args)+1)
args = append(args, field)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviaseds Here is a way to have inclusive date range when filtering the tasks. Also see other comment in this transaction file (I think we don't return the start/end date in this transaction)

field_names := []string{"group_id =", "created_by =", "task_status =", "task_type =", "start_date >=", "end_date <="}
var query string
var args []interface{}

for i, field := range query_fields {
if field != "" {
	if query != "" {
		query += " AND "
	}
	query += fmt.Sprintf("%s $%d", field_names[i], len(args)+1)
	args = append(args, field)
}
}

}
}

rows, err := pool.Query("SELECT task_id, group_id, created_by, created_date, task_status, task_type FROM task WHERE "+query, args...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add start/end date to SELECT statement. It will be in the WHERE query args but this doesn't return it like we probably should. You will also need to add it to the Scan below this

Copy link
Contributor

@MattCMcCoy MattCMcCoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@oliviaseds oliviaseds merged commit 4c2985b into main Feb 17, 2024
3 checks passed
@MattCMcCoy MattCMcCoy deleted the feature/task-management-crud-routes branch February 23, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants