Skip to content

Commit

Permalink
change months since last event to last action
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehobbs committed Mar 2, 2024
1 parent 9195062 commit 9b8a575
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
6 changes: 3 additions & 3 deletions frontend/ActivistList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1067,12 +1067,12 @@ function getDefaultColumns(chapter: string, view: string): Column[] {
showForAllChapters: true,
},
{
header: 'Mo. Since Last Event',
longHeader: 'Months Since Last Event',
header: 'Mo. Since Last Action',
longHeader: 'Months Since Last Action',
category: 'Event Attendance',
data: {
type: 'numeric',
data: 'months_since_last_event',
data: 'months_since_last_action',
readOnly: true,
colWidths: 50,
},
Expand Down
66 changes: 37 additions & 29 deletions model/activist.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,18 @@ SELECT
LIMIT 1)),
'') AS last_event_name,
@last_action := (
SELECT max(e.date) AS max_date
FROM event_attendance ea
JOIN activists inner_a ON inner_a.id = ea.activist_id
JOIN events e ON e.id = ea.event_id
WHERE inner_a.id = a.id and event_type in ("Action", "Outreach", "Frontline Surveillance", "Campaign Action", "Animal Care")
) AS last_action,
IFNULL(
TIMESTAMPDIFF(MONTH, DATE_FORMAT(@last_event, '%Y-%m-01'), NOW()),
TIMESTAMPDIFF(MONTH, DATE_FORMAT(@last_action, '%Y-%m-01'), NOW()),
9999
) AS months_since_last_event,
) AS months_since_last_action,
(SELECT COUNT(DISTINCT ea.event_id)
FROM event_attendance ea
Expand Down Expand Up @@ -294,15 +302,15 @@ type Activist struct {
}

type ActivistEventData struct {
FirstEvent mysql.NullTime `db:"first_event"`
LastEvent mysql.NullTime `db:"last_event"`
FirstEventName string `db:"first_event_name"`
LastEventName string `db:"last_event_name"`
MonthsSinceLastEvent int `db:"months_since_last_event"`
TotalEvents int `db:"total_events"`
TotalPoints int `db:"total_points"`
Active bool `db:"active"`
Status string
FirstEvent mysql.NullTime `db:"first_event"`
LastEvent mysql.NullTime `db:"last_event"`
FirstEventName string `db:"first_event_name"`
LastEventName string `db:"last_event_name"`
MonthsSinceLastAction int `db:"months_since_last_action"`
TotalEvents int `db:"total_events"`
TotalPoints int `db:"total_points"`
Active bool `db:"active"`
Status string
}

type ActivistMembershipData struct {
Expand Down Expand Up @@ -377,15 +385,15 @@ type ActivistJSON struct {
Birthday string `json:"dob"`
ChapterID int `json:"chapter_id"`

FirstEvent string `json:"first_event"`
LastEvent string `json:"last_event"`
FirstEventName string `json:"first_event_name"`
LastEventName string `json:"last_event_name"`
MonthsSinceLastEvent int `json:"months_since_last_event"`
TotalEvents int `json:"total_events"`
TotalPoints int `json:"total_points"`
Active bool `json:"active"`
Status string `json:"status"`
FirstEvent string `json:"first_event"`
LastEvent string `json:"last_event"`
FirstEventName string `json:"first_event_name"`
LastEventName string `json:"last_event_name"`
MonthsSinceLastAction int `json:"months_since_last_action"`
TotalEvents int `json:"total_events"`
TotalPoints int `json:"total_points"`
Active bool `json:"active"`
Status string `json:"status"`

ActivistLevel string `json:"activist_level"`
Source string `json:"source"`
Expand Down Expand Up @@ -605,15 +613,15 @@ func buildActivistJSONArray(activists []ActivistExtra) []ActivistJSON {
Accessibility: a.Accessibility,
Birthday: dob,

FirstEvent: firstEvent,
LastEvent: lastEvent,
FirstEventName: a.FirstEventName,
LastEventName: a.LastEventName,
MonthsSinceLastEvent: a.MonthsSinceLastEvent,
Status: a.Status,
TotalEvents: a.TotalEvents,
TotalPoints: a.TotalPoints,
Active: a.Active,
FirstEvent: firstEvent,
LastEvent: lastEvent,
FirstEventName: a.FirstEventName,
LastEventName: a.LastEventName,
MonthsSinceLastAction: a.MonthsSinceLastAction,
Status: a.Status,
TotalEvents: a.TotalEvents,
TotalPoints: a.TotalPoints,
Active: a.Active,

ActivistLevel: a.ActivistLevel,
Source: a.Source,
Expand Down

0 comments on commit 9b8a575

Please sign in to comment.