mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 10:46:06 +02:00
cleanup last active date
This commit is contained in:
parent
68ea6db752
commit
89ea577dc9
2 changed files with 23 additions and 25 deletions
|
@ -1975,33 +1975,34 @@ class MembersTable extends LoadTableBase {
|
|||
const options = { year: 'numeric', month: 'short', day: 'numeric' };
|
||||
|
||||
// Handle last_active values
|
||||
let last_active = NaN
|
||||
last_active = member.last_active;
|
||||
let last_active = member.last_active; // Changed to let to allow for potential modification
|
||||
let last_active_formatted = '';
|
||||
let last_active_sort_value = '';
|
||||
let last_active_sort_value = NaN;
|
||||
|
||||
// Handle 'Invited' or null/empty values differently from valid dates
|
||||
if (last_active !== invited) {
|
||||
try {
|
||||
// Try to parse the last_active as a valid date
|
||||
// Try to parse the last_active as a valid date
|
||||
// Check if last_active is valid before proceeding
|
||||
if (last_active) {
|
||||
if (last_active === invited) {
|
||||
last_active_formatted = invited;
|
||||
last_active_sort_value = invited; // Keep 'Invited' as a sortable value
|
||||
} else {
|
||||
const parsedDate = new Date(last_active);
|
||||
if (!isNaN(last_active)) {
|
||||
|
||||
try {
|
||||
if (!isNaN(parsedDate.getTime())) { // Check if the date is valid
|
||||
last_active_formatted = parsedDate.toLocaleDateString('en-US', options);
|
||||
last_active_sort_value = parsedDate.getTime(); // For sorting purposes
|
||||
} else {
|
||||
last_active_formatted='Invalid date';
|
||||
last_active_sort_value = 'Invalid date';
|
||||
throw new Error('Invalid date'); // Throw an error to catch in catch block
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Error parsing date: ${last_active}. Error: ${e}`);
|
||||
last_active_formatted='Invalid date'
|
||||
last_active_formatted = 'Invalid date';
|
||||
last_active_sort_value = 'Invalid date';
|
||||
}
|
||||
} else {
|
||||
// Handle 'Invited' or null
|
||||
last_active = invited;
|
||||
last_active_formatted = invited;
|
||||
last_active_sort_value = invited; // Keep 'Invited' as a sortable string
|
||||
}
|
||||
} else { // last_active is null or undefined
|
||||
last_active_formatted = 'Invalid date';
|
||||
last_active_sort_value = 'Invalid date'; // Default value for invalid or missing last_active
|
||||
}
|
||||
|
||||
const action_url = member.action_url;
|
||||
|
|
|
@ -113,8 +113,6 @@ def initial_permissions_search(portfolio):
|
|||
|
||||
def initial_invitations_search(portfolio):
|
||||
"""Perform initial invitations search and get related DomainInvitation data based on the email."""
|
||||
|
||||
|
||||
# Get DomainInvitation query for matching email
|
||||
domain_invitations = DomainInvitation.objects.filter(
|
||||
email=OuterRef('email'),
|
||||
|
@ -127,7 +125,6 @@ def initial_invitations_search(portfolio):
|
|||
output_field=CharField()
|
||||
)
|
||||
)
|
||||
|
||||
invitations = PortfolioInvitation.objects.filter(portfolio=portfolio)
|
||||
invitations = invitations.annotate(
|
||||
first_name=Value(None, output_field=CharField()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue