Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frameworks/FSharp/oxpecker/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"framework": "oxpecker",
"maintainers": ["Lanayx"],
"tests": [
{
"default": {
Expand Down
6 changes: 3 additions & 3 deletions frameworks/FSharp/oxpecker/src/App/App.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="10.0.100" />
<PackageReference Include="Oxpecker" Version="1.5.0" />
<PackageReference Include="Oxpecker.ViewEngine" Version="1.1.0" />
<PackageReference Include="Npgsql" Version="9.0.4" />
<PackageReference Include="Oxpecker" Version="2.0.0" />
<PackageReference Include="Oxpecker.ViewEngine" Version="2.0.0" />
<PackageReference Include="Npgsql" Version="10.0.0" />
<PackageReference Include="SpanJson" Version="4.2.1" />
</ItemGroup>
</Project>
16 changes: 6 additions & 10 deletions frameworks/FSharp/oxpecker/src/App/Db.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,15 @@ module Db =
cmd.Parameters.Add(id) |> ignore
struct(cmd, id)

let private readSingleRow (cmd: NpgsqlCommand) =
task {
use! rdr = cmd.ExecuteReaderAsync(CommandBehavior.SingleRow)
let! _ = rdr.ReadAsync()
return { id = rdr.GetInt32(0); randomnumber = rdr.GetInt32(1) }
}

let loadSingleRow () =
task {
use db = new NpgsqlConnection(ConnectionString)
let struct(cmd', _) = createReadCommand db
use cmd = cmd'
do! db.OpenAsync()
return! readSingleRow cmd
use! rdr = cmd.ExecuteReaderAsync(CommandBehavior.SingleRow)
let! _ = rdr.ReadAsync()
return { id = rdr.GetInt32(0); randomnumber = rdr.GetInt32(1) }
}

let private readMultipleRows (count: int) (conn: NpgsqlConnection) =
Expand All @@ -54,8 +49,9 @@ module Db =
let struct(cmd', idParam) = createReadCommand conn
use cmd = cmd'
for i in 0..result.Length-1 do
let! row = readSingleRow cmd
result[i] <- row
use! rdr = cmd.ExecuteReaderAsync(CommandBehavior.SingleRow)
let! _ = rdr.ReadAsync()
result[i] <- { id = rdr.GetInt32(0); randomnumber = rdr.GetInt32(1) }
idParam.TypedValue <- Random.Shared.Next(1, 10001)
return result
}
Expand Down
2 changes: 1 addition & 1 deletion frameworks/FSharp/oxpecker/src/App/RenderHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
sb.Append(ht.Head) |> ignore
for fortune in fortunesData do
(tr() {
td() { raw <| string fortune.id }
td() { fortune.id }
td() { fortune.message }
}).Render(sb)
sb.Append(ht.Tail) |> ignore
Expand Down
Loading