Skip to content

Commit

Permalink
Bumping version to 0.0.33
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 5, 2018
1 parent e93f470 commit 2396c5c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 46 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Release Notes

## 0.0.32 - 2018-10-05
## 0.0.33 - 2018-10-05

* Initial release
32 changes: 0 additions & 32 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,37 +217,6 @@ Target.create "CreateDockerImage" (fun _ ->
if result <> 0 then failwith "Docker build failed"
)


Target.createFinal "KillProcess" (fun _ ->
Process.killAllByName "dotnet"
Process.killAllByName "dotnet.exe"
)

Target.create "TestDockerImage" (fun _ ->
Target.activateFinal "KillProcess"
let testImageName = "test"

let result =
Process.execSimple (fun info ->
{ info with
FileName = "docker"
Arguments = sprintf "run -d -p 127.0.0.1:8085:8085 --rm --name %s -it %s/%s" testImageName dockerUser dockerImageName }) TimeSpan.MaxValue
if result <> 0 then failwith "Docker run failed"

System.Threading.Thread.Sleep 5000 |> ignore // give server some time to start

// !! clientTestExecutables
// |> Testing.Expecto.run (fun p -> { p with Parallel = false } )
// |> ignore

let result =
Process.execSimple (fun info ->
{ info with
FileName = "docker"
Arguments = sprintf "stop %s" testImageName }) TimeSpan.MaxValue
if result <> 0 then failwith "Docker stop failed"
)

Target.create "PrepareRelease" (fun _ ->
Fake.Tools.Git.Branches.checkout "" false "master"
Fake.Tools.Git.CommandHelper.directRunGitCommand "" "fetch origin" |> ignore
Expand Down Expand Up @@ -311,7 +280,6 @@ open Fake.Core.TargetOperators
==> "Build"
==> "BundleClient"
==> "CreateDockerImage"
==> "TestDockerImage"
==> "PrepareRelease"
==> "Deploy"

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Thoth.Json
open Thoth.Json.Net
#endif

open Shared
open ServerCore.Domain
open Fulma

type Model = {
Expand Down
4 changes: 2 additions & 2 deletions src/Client/ReleaseNotes.fs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module internal ReleaseNotes

let Version = "0.0.32"
let Version = "0.0.33"

let IsPrerelease = false

let Notes = """
# Release Notes
## 0.0.32 - 2018-10-05
## 0.0.33 - 2018-10-05
* Initial release
"""
3 changes: 2 additions & 1 deletion src/PiServer/PiServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ open FSharp.Control.Tasks.ContextInsensitive
open Microsoft.AspNetCore.NodeServices
open System.Runtime.InteropServices
open Thoth.Json.Net
open Shared
open ServerCore.Domain

open System.Threading.Tasks

let tagServer = "https://audio-hub.azurewebsites.net"
Expand Down
65 changes: 59 additions & 6 deletions src/Server/AzureTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module ServerCode.Storage.AzureTable
open Microsoft.WindowsAzure.Storage
open Microsoft.WindowsAzure.Storage.Table
open System.Threading.Tasks
open FSharp.Control.Tasks.ContextInsensitive

type AzureConnection =
| AzureConnection of string
Expand Down Expand Up @@ -117,11 +118,63 @@ let inline getOptionalDoubleProperty (propName:string) (entity: DynamicTableEnti
with
| exn -> failwithf "Could not get Double value of property %s for entity %s %s. Message: %s" propName entity.PartitionKey entity.RowKey exn.Message

#if DEBUG
let storageConnectionString = "UseDevelopmentStorage=true"
#else
let storageConnectionString = System.Environment.GetEnvironmentVariable("CUSTOMCONNSTR_STORAGE")
#endif

let storageConnectionString =
let str = System.Environment.GetEnvironmentVariable("CUSTOMCONNSTR_STORAGE")
if isNull str then
"UseDevelopmentStorage=true"
else
str

let connectionToAzureStorage = (AzureConnection storageConnectionString).Connect()
let connection = (AzureConnection storageConnectionString).Connect()

let tagsTable = getTable "tags" connection


open ServerCore.Domain
open Thoth.Json.Net


let mapTag (entity: DynamicTableEntity) : Tag =
{ Token = entity.RowKey
Action =
match Decode.fromString TagAction.Decoder (getStringProperty "Action" entity) with
| Error msg -> failwith msg
| Ok action -> action }


let saveTag (userID:string) (tag:Tag) =
let entity = DynamicTableEntity()
entity.PartitionKey <- userID
entity.RowKey <- tag.Token
entity.Properties.["Action"] <- EntityProperty.GeneratePropertyForString (TagAction.Encoder tag.Action |> Encode.toString 0)
let operation = TableOperation.InsertOrReplace entity
tagsTable.ExecuteAsync operation


let getTag userID token = task {
let query = TableOperation.Retrieve(userID, token)
let! r = tagsTable.ExecuteAsync(query)
if r.HttpStatusCode <> 200 then
return None
else
let result = r.Result :?> DynamicTableEntity
if isNull result then return None else return Some(mapTag result)
}

let getAllTagsForUser userID = task {
let rec getResults token = task {
let query = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, userID)
let! result = tagsTable.ExecuteQuerySegmentedAsync(TableQuery(FilterString = query), token)
let token = result.ContinuationToken
let result = result |> Seq.toList
if isNull token then
return result
else
let! others = getResults token
return result @ others }

let! results = getResults null

return [| for result in results -> mapTag result |]
}
8 changes: 6 additions & 2 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ open Microsoft.Extensions.DependencyInjection
open Giraffe
open Saturn
open FSharp.Control.Tasks.ContextInsensitive
open Shared
open ServerCore.Domain

open Thoth.Json.Net
open ServerCode.Storage

let port = 8085us

Expand All @@ -22,11 +24,13 @@ let mp3Server = sprintf "%s/api/audio/mp3" mediaServer

let xs = [for x in System.Environment.GetEnvironmentVariables().Keys -> string x ]

let tagsFromDB = AzureTable.getAllTagsForUser "sforkmann@gmail.com" |> Async.AwaitTask |> Async.RunSynchronously

let tags = {
Tags = [|
{ Token = "celeb"; Action = TagAction.PlayMusik (sprintf @"%s/custom/%s" mp3Server "Celebrate") }
{ Token = "stop"; Action = TagAction.StopMusik }
|]
|] |> Array.append tagsFromDB
}

let allTags =
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Shared.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared
namespace ServerCore.Domain

#if FABLE_COMPILER
open Thoth.Json
Expand Down

0 comments on commit 2396c5c

Please sign in to comment.