Search, Paging, and "As of" Date #10
@ -64,7 +64,7 @@ type AppDbContext with
|
|||||||
member this.CountMembersForSmallGroup gId =
|
member this.CountMembersForSmallGroup gId =
|
||||||
this.Members.CountAsync (fun m -> m.smallGroupId = gId)
|
this.Members.CountAsync (fun m -> m.smallGroupId = gId)
|
||||||
|
|
||||||
(*-- PRAYER REQUEST EXTENSIONS *)
|
(*-- PRAYER REQUEST EXTENSIONS --*)
|
||||||
|
|
||||||
/// Get a prayer request by its Id
|
/// Get a prayer request by its Id
|
||||||
member this.TryRequestById reqId =
|
member this.TryRequestById reqId =
|
||||||
@ -108,6 +108,27 @@ type AppDbContext with
|
|||||||
member this.CountRequestsByChurch cId =
|
member this.CountRequestsByChurch cId =
|
||||||
this.PrayerRequests.CountAsync (fun pr -> pr.smallGroup.churchId = cId)
|
this.PrayerRequests.CountAsync (fun pr -> pr.smallGroup.churchId = cId)
|
||||||
|
|
||||||
|
/// Get all (or active) requests for a small group as of now or the specified date
|
||||||
|
member this.SearchRequestsForSmallGroup (grp : SmallGroup) (searchTerm : string) pageNbr : PrayerRequest seq =
|
||||||
|
let skip = (pageNbr - 1) * 100
|
||||||
|
upcast (
|
||||||
|
this.PrayerRequests
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(fun pr -> pr.smallGroupId = grp.smallGroupId && pr.text.Contains(searchTerm.ToLowerInvariant()))
|
||||||
|
|> function
|
||||||
|
// Sort
|
||||||
|
| query when grp.preferences.requestSort = "D" ->
|
||||||
|
query.OrderByDescending(fun pr -> pr.updatedDate)
|
||||||
|
.ThenByDescending(fun pr -> pr.enteredDate)
|
||||||
|
.ThenBy(fun pr -> pr.requestor)
|
||||||
|
| query ->
|
||||||
|
query.OrderBy(fun pr -> pr.requestor)
|
||||||
|
.ThenByDescending(fun pr -> pr.updatedDate)
|
||||||
|
.ThenByDescending(fun pr -> pr.enteredDate)
|
||||||
|
|> function
|
||||||
|
// Pagination
|
||||||
|
| query -> query.Skip(skip).Take(100))
|
||||||
|
|
||||||
(*-- SMALL GROUP EXTENSIONS --*)
|
(*-- SMALL GROUP EXTENSIONS --*)
|
||||||
|
|
||||||
/// Find a small group by its Id
|
/// Find a small group by its Id
|
||||||
|
@ -156,6 +156,8 @@ and [<CLIMutable; NoComparison; NoEquality>] ListPreferences =
|
|||||||
timeZoneId : TimeZoneId
|
timeZoneId : TimeZoneId
|
||||||
/// The time zone information
|
/// The time zone information
|
||||||
timeZone : TimeZone
|
timeZone : TimeZone
|
||||||
|
/// The number of requests displayed per page
|
||||||
|
pageSize : int
|
||||||
}
|
}
|
||||||
with
|
with
|
||||||
/// A set of preferences with their default values
|
/// A set of preferences with their default values
|
||||||
@ -177,6 +179,7 @@ and [<CLIMutable; NoComparison; NoEquality>] ListPreferences =
|
|||||||
isPublic = false
|
isPublic = false
|
||||||
timeZoneId = "America/Denver"
|
timeZoneId = "America/Denver"
|
||||||
timeZone = TimeZone.empty
|
timeZone = TimeZone.empty
|
||||||
|
pageSize = 100
|
||||||
}
|
}
|
||||||
/// Configure EF for this entity
|
/// Configure EF for this entity
|
||||||
static member internal configureEF (mb : ModelBuilder) =
|
static member internal configureEF (mb : ModelBuilder) =
|
||||||
@ -188,78 +191,83 @@ and [<CLIMutable; NoComparison; NoEquality>] ListPreferences =
|
|||||||
m.Property(fun e -> e.daysToKeepNew)
|
m.Property(fun e -> e.daysToKeepNew)
|
||||||
.HasColumnName("DaysToKeepNew")
|
.HasColumnName("DaysToKeepNew")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(7)
|
.HasDefaultValue 7
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.daysToExpire)
|
m.Property(fun e -> e.daysToExpire)
|
||||||
.HasColumnName("DaysToExpire")
|
.HasColumnName("DaysToExpire")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(14)
|
.HasDefaultValue 14
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.longTermUpdateWeeks)
|
m.Property(fun e -> e.longTermUpdateWeeks)
|
||||||
.HasColumnName("LongTermUpdateWeeks")
|
.HasColumnName("LongTermUpdateWeeks")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(4)
|
.HasDefaultValue 4
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.emailFromName)
|
m.Property(fun e -> e.emailFromName)
|
||||||
.HasColumnName("EmailFromName")
|
.HasColumnName("EmailFromName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("PrayerTracker")
|
.HasDefaultValue "PrayerTracker"
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.emailFromAddress)
|
m.Property(fun e -> e.emailFromAddress)
|
||||||
.HasColumnName("EmailFromAddress")
|
.HasColumnName("EmailFromAddress")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("prayer@djs-consulting.com")
|
.HasDefaultValue "prayer@djs-consulting.com"
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.listFonts)
|
m.Property(fun e -> e.listFonts)
|
||||||
.HasColumnName("ListFonts")
|
.HasColumnName("ListFonts")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("Century Gothic,Tahoma,Luxi Sans,sans-serif")
|
.HasDefaultValue "Century Gothic,Tahoma,Luxi Sans,sans-serif"
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.headingColor)
|
m.Property(fun e -> e.headingColor)
|
||||||
.HasColumnName("HeadingColor")
|
.HasColumnName("HeadingColor")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("maroon")
|
.HasDefaultValue "maroon"
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.lineColor)
|
m.Property(fun e -> e.lineColor)
|
||||||
.HasColumnName("LineColor")
|
.HasColumnName("LineColor")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("navy")
|
.HasDefaultValue "navy"
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.headingFontSize)
|
m.Property(fun e -> e.headingFontSize)
|
||||||
.HasColumnName("HeadingFontSize")
|
.HasColumnName("HeadingFontSize")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(16)
|
.HasDefaultValue 16
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.textFontSize)
|
m.Property(fun e -> e.textFontSize)
|
||||||
.HasColumnName("TextFontSize")
|
.HasColumnName("TextFontSize")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(12)
|
.HasDefaultValue 12
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.requestSort)
|
m.Property(fun e -> e.requestSort)
|
||||||
.HasColumnName("RequestSort")
|
.HasColumnName("RequestSort")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(1)
|
.HasMaxLength(1)
|
||||||
.HasDefaultValue("D")
|
.HasDefaultValue "D"
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.groupPassword)
|
m.Property(fun e -> e.groupPassword)
|
||||||
.HasColumnName("GroupPassword")
|
.HasColumnName("GroupPassword")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("")
|
.HasDefaultValue ""
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.defaultEmailType)
|
m.Property(fun e -> e.defaultEmailType)
|
||||||
.HasColumnName("DefaultEmailType")
|
.HasColumnName("DefaultEmailType")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(EmailType.Html)
|
.HasDefaultValue EmailType.Html
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.isPublic)
|
m.Property(fun e -> e.isPublic)
|
||||||
.HasColumnName("IsPublic")
|
.HasColumnName("IsPublic")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue(false)
|
.HasDefaultValue false
|
||||||
|> ignore
|
|> ignore
|
||||||
m.Property(fun e -> e.timeZoneId)
|
m.Property(fun e -> e.timeZoneId)
|
||||||
.HasColumnName("TimeZoneId")
|
.HasColumnName("TimeZoneId")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasDefaultValue("America/Denver")
|
.HasDefaultValue "America/Denver"
|
||||||
|
|> ignore
|
||||||
|
m.Property(fun e -> e.pageSize)
|
||||||
|
.HasColumnName("PageSize")
|
||||||
|
.IsRequired()
|
||||||
|
.HasDefaultValue 100
|
||||||
|> ignore)
|
|> ignore)
|
||||||
|> ignore
|
|> ignore
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ type ListPreferencesTable =
|
|||||||
requestSort : OperationBuilder<AddColumnOperation>
|
requestSort : OperationBuilder<AddColumnOperation>
|
||||||
textFontSize : OperationBuilder<AddColumnOperation>
|
textFontSize : OperationBuilder<AddColumnOperation>
|
||||||
timeZoneId : OperationBuilder<AddColumnOperation>
|
timeZoneId : OperationBuilder<AddColumnOperation>
|
||||||
|
pageSize : OperationBuilder<AddColumnOperation>
|
||||||
}
|
}
|
||||||
|
|
||||||
type MemberTable =
|
type MemberTable =
|
||||||
@ -187,9 +188,10 @@ type InitialDatabase () =
|
|||||||
lineColor = table.Column<string> (name = "LineColor", nullable = false, defaultValue = "navy")
|
lineColor = table.Column<string> (name = "LineColor", nullable = false, defaultValue = "navy")
|
||||||
listFonts = table.Column<string> (name = "ListFonts", nullable = false, defaultValue = "Century Gothic,Tahoma,Luxi Sans,sans-serif")
|
listFonts = table.Column<string> (name = "ListFonts", nullable = false, defaultValue = "Century Gothic,Tahoma,Luxi Sans,sans-serif")
|
||||||
longTermUpdateWeeks = table.Column<int> (name = "LongTermUpdateWeeks", nullable = false, defaultValue = 4)
|
longTermUpdateWeeks = table.Column<int> (name = "LongTermUpdateWeeks", nullable = false, defaultValue = 4)
|
||||||
requestSort = table.Column<string> (name = "RequestSort", maxLength = Nullable<int> 1, nullable = false, defaultValue = "D")
|
requestSort = table.Column<string> (name = "RequestSort", nullable = false, defaultValue = "D", maxLength = Nullable<int> 1)
|
||||||
textFontSize = table.Column<int> (name = "TextFontSize", nullable = false, defaultValue = 12)
|
textFontSize = table.Column<int> (name = "TextFontSize", nullable = false, defaultValue = 12)
|
||||||
timeZoneId = table.Column<string> (name = "TimeZoneId", nullable = false, defaultValue = "America/Denver")
|
timeZoneId = table.Column<string> (name = "TimeZoneId", nullable = false, defaultValue = "America/Denver")
|
||||||
|
pageSize = table.Column<int> (name = "PageSize", nullable = false, defaultValue = 100)
|
||||||
}),
|
}),
|
||||||
constraints =
|
constraints =
|
||||||
fun table ->
|
fun table ->
|
||||||
|
@ -49,6 +49,7 @@ type AppDbContextModelSnapshot () =
|
|||||||
b.Property<string>("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore
|
b.Property<string>("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore
|
||||||
b.Property<int>("textFontSize").ValueGeneratedOnAdd().HasDefaultValue(12) |> ignore
|
b.Property<int>("textFontSize").ValueGeneratedOnAdd().HasDefaultValue(12) |> ignore
|
||||||
b.Property<string>("timeZoneId").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("America/Denver") |> ignore
|
b.Property<string>("timeZoneId").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("America/Denver") |> ignore
|
||||||
|
b.Property<int>("pageSize").IsRequired().ValueGeneratedOnAdd().HasDefaultValue(100) |> ignore
|
||||||
b.HasKey("smallGroupId") |> ignore
|
b.HasKey("smallGroupId") |> ignore
|
||||||
b.HasIndex("timeZoneId") |> ignore
|
b.HasIndex("timeZoneId") |> ignore
|
||||||
b.ToTable("ListPreference") |> ignore)
|
b.ToTable("ListPreference") |> ignore)
|
||||||
|
Loading…
Reference in New Issue
Block a user