Skip to content

Commit

Permalink
Adding cleanup script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrrv committed Apr 25, 2024
1 parent 4195252 commit ead702d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Cleanup/Cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#Role=Admin

global q

# Active Involvements with Past End Dates
print("<h2>Active Involvements with Past End Dates</h2>")
print("<p>Each of these involvements has an end date in the past, but is listed as Active. Either the dates need to "
"be updated, or the status should be changed to Inactive.</p>")

print("<ul>")
sql = """SELECT TOP 100 OrganizationId, OrganizationName
FROM Organizations WHERE LastMeetingDate < GETDATE() AND LastMeetingDate IS NOT NULL AND OrganizationStatusId = 30"""
for i in q.QuerySql(sql, {}):
print("<li><a href=\"/Org/{0}\">{1} ({0})</a></li>".format(i.OrganizationId, i.OrganizationName))
print("</ul>")


# Main Fellowships w/o Attendance
print("<h2>Active Main Fellowship Involvements without attendance</h2>")
print("<p>Each of these involvements has not reported attendance within the last 30 days.</p>")

print("<ul>")
sql = """
WITH meetingsCte AS ( -- Select Meetings that match what we want to see
SELECT m.OrganizationId, m.MeetingDate
FROM Meetings m
WHERE m.MeetingDate > DATEADD(day, -30, GETDATE())
AND m.MeetingDate < GETDATE()
AND m.NumPresent > 3
)
SELECT o.OrganizationId, o.OrganizationName FROM Organizations o
LEFT JOIN meetingsCte m ON o.OrganizationId = m.OrganizationId
WHERE (o.LastMeetingDate > DATEADD(day, -30, GETDATE()) OR o.LastMeetingDate IS NULL)
AND o.OrganizationStatusId = 30
AND o.IsBibleFellowshipOrg = 1
AND m.MeetingDate IS NULL
"""
for i in q.QuerySql(sql, {}):
print("<li><a href=\"/Org/{0}\">{1} ({0})</a></li>".format(i.OrganizationId, i.OrganizationName))
print("</ul>")
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ icons on volunteer nametags.

- [**Classroom Redirect**](ClassroomRedirect) - This tool makes it easier for volunteers to access their Classroom Dashboards.

- [**Cleanup**](Cleanup) - Some cleanup required a human touch. This script helps you find and fix those records. (This
script is likely to be updated and expanded often; check back periodically for improvements.)

- [**Demographic Analysis**](DemographicAnalysis) - This Blue Toolbar report readily allows you to see the basic breakdown of demographic
groups, like age groups and Resident Codes for any situation where you see a Blue Toolbar.

Expand Down

0 comments on commit ead702d

Please sign in to comment.