diff --git a/Cleanup/Cleanup.py b/Cleanup/Cleanup.py new file mode 100644 index 0000000..7a3327b --- /dev/null +++ b/Cleanup/Cleanup.py @@ -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>") \ No newline at end of file diff --git a/README.md b/README.md index 55c0d6a..8a74844 100644 --- a/README.md +++ b/README.md @@ -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.