-
Notifications
You must be signed in to change notification settings - Fork 0
[Newsletter] changes to broadcast and job posting services, along with added google sheets functionality #130
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
Conversation
…ta so that we can extract hyperlinks that were used by the google sheets insert functionality
…d better error handling for dates
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
|
|
||
| # Common CSS for styling the newsletter sections | ||
| # Updated CSS for styling the newsletter to match the provided image | ||
| css = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to modularize or put this into utils where you can call that constant? This takes way too much space and it's hard to understand the core functionality.
| </style> | ||
| """ | ||
|
|
||
| # Job sources text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the job sources change in the long run? I think it'd be easier to maintain if we had a const tracking the links and names, something along the lines of:
JOB_SOURCE_LIST = {
"tech": [{name: "...", link: "..."}, ...],
"finance": [...],
...
}
and you can iterate through it and embed as an fstring. If it's too complicated, feel free to leave it be.
| """ | ||
| JOBS_SHEET_ID = "15za1luZR08YmmBIFOAk6-GJB3T22StEuiZgFFuJeKW0" | ||
| try: | ||
| # First get the sheet data with FORMULA render option to parse hyperlink formulas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Get sheet data with FORMULA render option to parse hyperlink formulas"
| sheet_data = self.gs.get_sheet_with_grid_data(JOBS_SHEET_ID, "2027 Opportunities Tracker") | ||
|
|
||
| # 2. Separate headers from rows | ||
| headers = response["values"][5] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to PR changes, but I'm wondering if we should create consts like HEADER_DIVIDER (maybe there's a better naming) to use instead of numbers so it'd be response["values"][HEADER_DIVIDER]. Thoughts?
chalicelib/api/broadcast.py
Outdated
|
|
||
| return | ||
|
|
||
| beta_list = ["[email protected]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this? I don't see it being used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may have been an accidental commit. I wanted to keep this list locally so I can send periodic test emails to the listed recipients
jinyoungbang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding more reviews - let me know if you have any questions!
| return True | ||
| return False | ||
| except Exception: | ||
| # hotfix for if dateStr is not in the format "Mon DD", but intead is in the format 'DDd', i.e. "15d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fix spelling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a temporary hotfix, can you write a TODO inside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| # Return empty grid data, as our test is using formula-based hyperlinks | ||
| return {"sheets": [{"data": [{"rowData": []}]}]} | ||
|
|
||
| def get_hyperlink_from_grid_data(self, sheet_data, row_idx, col_idx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might be missing some context, but if this won't be used, what's the purpose of this fixture/function?
|
@vinli0921 Please update the PR name to be more descriptive! |
… better code readability
…ty, updated isMoreThanOneWeekAgo for more robust error handling and a TODO
| assert job_service.isMoreThanOneWeekAgo(date_old) is True | ||
|
|
||
|
|
||
| def test_get_finance_jobs_ui_hyperlink(job_service): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, however test code is a bit verbose. In cases like this, we usually mock the return values, and inject them. Here is an example of what I'd do (but I have no clue if this technically works as there might be more dependencies involved):
from unittest.mock import MagicMock # Import this built-in Python mock library
def test_get_finance_jobs_ui_hyperlink(job_service):
service = job_service
mocked_gs = MagicMock()
mocked_gs.get_all_cells.return_value = {
"values": [
[], [], [], [], [],
["Company", "Opportunity", "Link", "Deadline"],
["CompanyC", "Analyst", 'Click here', "44197"]
]
}
mocked_gs.get_sheet_with_grid_data.return_value = {"sheets": [{"data": [{"rowData": []}]}]}
mocked_gs.get_hyperlink_from_grid_data.return_value = "http://ui-inserted-link.com"
service.gs = mocked_gs # Inject mocked dependency
jobs = service.getFinanceJobs()
assert len(jobs) == 1
assert jobs[0]["company"] == "CompanyC"
assert jobs[0]["role"] == "Analyst"
assert jobs[0]["link"] == "http://ui-inserted-link.com"
assert jobs[0]["date"] == "Jan 01"If refactoring is too complicated, just leave it be but consider it for next time!
|
|
||
| job_service.gs = DummyGS() | ||
|
|
||
| jobs = job_service.getFinanceJobs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk how I didn't catch this last time, but all methods in Python (per style guide) should be in snake_case – maybe you can create a chore PR just fixing this but putting it out there for consistency purposes.
What does this PR do?
This PR fixes the issue with hyperlink extraction from Google Sheets by implementing a dual approach to handle both formula-based and UI-inserted hyperlinks. Previously, the system was only able to extract hyperlinks created using the =HYPERLINK() formula, resulting in missing links for cells where hyperlinks were inserted through the Google Sheets UI. The fix:
Additionally, this PR implements significant UI improvements to the newsletter:
This change ensures all job links can be properly extracted from the RecruitU spreadsheet regardless of how they were created in Google Sheets, while also delivering a significantly improved visual experience for newsletter recipients.
Type of change
Tests Performed
Screenshots
Additional Comments