mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 18:56:15 +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' };
|
const options = { year: 'numeric', month: 'short', day: 'numeric' };
|
||||||
|
|
||||||
// Handle last_active values
|
// Handle last_active values
|
||||||
let last_active = NaN
|
let last_active = member.last_active; // Changed to let to allow for potential modification
|
||||||
last_active = member.last_active;
|
|
||||||
let last_active_formatted = '';
|
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
|
// Check if last_active is valid before proceeding
|
||||||
if (last_active !== invited) {
|
if (last_active) {
|
||||||
try {
|
if (last_active === invited) {
|
||||||
// Try to parse the last_active as a valid date
|
last_active_formatted = invited;
|
||||||
// Try to parse the last_active as a valid date
|
last_active_sort_value = invited; // Keep 'Invited' as a sortable value
|
||||||
|
} else {
|
||||||
const parsedDate = new Date(last_active);
|
const parsedDate = new Date(last_active);
|
||||||
if (!isNaN(last_active)) {
|
|
||||||
last_active_formatted = parsedDate.toLocaleDateString('en-US', options);
|
try {
|
||||||
last_active_sort_value = parsedDate.getTime(); // For sorting purposes
|
if (!isNaN(parsedDate.getTime())) { // Check if the date is valid
|
||||||
} else {
|
last_active_formatted = parsedDate.toLocaleDateString('en-US', options);
|
||||||
last_active_formatted='Invalid date';
|
last_active_sort_value = parsedDate.getTime(); // For sorting purposes
|
||||||
|
} else {
|
||||||
|
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_sort_value = 'Invalid date';
|
last_active_sort_value = 'Invalid date';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
console.error(`Error parsing date: ${last_active}. Error: ${e}`);
|
|
||||||
last_active_formatted='Invalid date'
|
|
||||||
}
|
}
|
||||||
} else {
|
} else { // last_active is null or undefined
|
||||||
// Handle 'Invited' or null
|
last_active_formatted = 'Invalid date';
|
||||||
last_active = invited;
|
last_active_sort_value = 'Invalid date'; // Default value for invalid or missing last_active
|
||||||
last_active_formatted = invited;
|
|
||||||
last_active_sort_value = invited; // Keep 'Invited' as a sortable string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const action_url = member.action_url;
|
const action_url = member.action_url;
|
||||||
|
|
|
@ -113,8 +113,6 @@ def initial_permissions_search(portfolio):
|
||||||
|
|
||||||
def initial_invitations_search(portfolio):
|
def initial_invitations_search(portfolio):
|
||||||
"""Perform initial invitations search and get related DomainInvitation data based on the email."""
|
"""Perform initial invitations search and get related DomainInvitation data based on the email."""
|
||||||
|
|
||||||
|
|
||||||
# Get DomainInvitation query for matching email
|
# Get DomainInvitation query for matching email
|
||||||
domain_invitations = DomainInvitation.objects.filter(
|
domain_invitations = DomainInvitation.objects.filter(
|
||||||
email=OuterRef('email'),
|
email=OuterRef('email'),
|
||||||
|
@ -127,7 +125,6 @@ def initial_invitations_search(portfolio):
|
||||||
output_field=CharField()
|
output_field=CharField()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
invitations = PortfolioInvitation.objects.filter(portfolio=portfolio)
|
invitations = PortfolioInvitation.objects.filter(portfolio=portfolio)
|
||||||
invitations = invitations.annotate(
|
invitations = invitations.annotate(
|
||||||
first_name=Value(None, output_field=CharField()),
|
first_name=Value(None, output_field=CharField()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue