Skip to content

Slack - Get Student Info Endpoint#83

Merged
NickGuerrero merged 6 commits intomainfrom
ConlynPattison/Slack-GetStudentInfo
Mar 21, 2026
Merged

Slack - Get Student Info Endpoint#83
NickGuerrero merged 6 commits intomainfrom
ConlynPattison/Slack-GetStudentInfo

Conversation

@ConlynPattison
Copy link
Copy Markdown
Collaborator

@ConlynPattison ConlynPattison commented Feb 25, 2026

Slack - Get Student Info Endpoint

This request adds an endpoint at GET /api/slack/student_info for the Slack Bolt application, which the student initiates to acquire the student's information. All student information is gathered from the Postgres database. Students are authenticated under the assumption that their Slack email address is either their primary email address or one of their alternate email addresses.

The shape of the JSON data response resembles the following:

{
  "cti_id": 1,
  "fname": "John",
  "lname": "Doe",
  "pname": "Johnny",
  "institution": "UC Berkeley",
  "target_year": 2025,
  "join_date": "2023-09-01T00:00:00",
  "gender": "Male",
  "ethnicities_agg": ["Hispanic", "Asian"],
  "birthday": "2004-05-15",
  "first_gen": true,
  "email": "john.doe@example.com",
  "primary_email": "john.doe@example.com",
  "alternate_emails": ["john.alt@example.com", "john.doe.alt@example.com"]
}

Issues Fixed

Notes

  • This PR does not address badges or attendance tracking/history, but these items will also need to be fetched from this application for the second half of the Slack app home page
  • No rate limiting is currently applied/implemented

Tests

Unit testing has been written to cover the fetch_student_info service function. Run these tests with:

pytest -k test_fetch_student_info_service.py
image

Checklist

  • I've reviewed the contribution guide
  • I've confirmed the changes work on my machine
  • This pull request is ready for review

@ConlynPattison ConlynPattison changed the title Conlyn pattison/slack get student info Slack - Get Student Info Endpoint Feb 25, 2026
# Setup
mock_result = Mock()
mock_result._asdict.return_value = student_row_data
mock_postgresql_db.execute.return_value.first.return_value = mock_result
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This fixture is a bit odd; All the fixture does is return static data, but in the tests, they need to be loaded in the database object anyway (for each test). I understand having a custom fixture for this class of tests, but I feel like the data loading functionality should have either been part of the fixture or assigned to a helper function.


assert result['first_gen'] is True

def test_fetch_student_info_with_first_generation_false(self, mock_postgresql_db, student_row_data):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This test could be merged with the above test (using parameterized tests), especially since the code is the same, only the values are changing.


assert result['first_gen'] is False

def test_fetch_student_info_with_different_target_years(self, mock_postgresql_db, student_row_data):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

On an initial pass, I assumed that these tests were redundant, but then I remembered the problems we had with re-factoring. While these tests are very unlikely to ever fail, I appreciate the added safeguards.

Copy link
Copy Markdown
Owner

@NickGuerrero NickGuerrero left a comment

Choose a reason for hiding this comment

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

  • Endpoint logic looks good, addresses the issue correctly
  • Code is very straightforward
  • Tests could be condensed, but functionality is sufficient
    This is meant to work with the Slack application, more optimizations or changes could be made with more Slack development. I've changed my mind on the original proposed revision, I don't think it's needed given our current use case. Should be ready for merge.

@NickGuerrero NickGuerrero merged commit 2d71eeb into main Mar 21, 2026
2 checks passed
@NickGuerrero NickGuerrero deleted the ConlynPattison/Slack-GetStudentInfo branch March 21, 2026 20:06
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.

2 participants