Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add temperature #2

Open
wants to merge 3 commits into
base: add-pipeline
Choose a base branch
from
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
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: .NET Core

on:
push:
branches: [ add-pipeline ]
pull_request:
branches: [ add-pipeline ]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Change folder and install depen
run: cd fitnessdb-dbup; dotnet restore
- name: Run
env: # as an environment variable
ConnectionString: ${{ secrets.CONNECTIONSTRING }}
SQLPassword: ${{ secrets.SQLPASSWORD }}
run: cd fitnessdb-dbup; dotnet run

27 changes: 27 additions & 0 deletions fitnessdb-dbup/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/database-migration.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions fitnessdb-dbup/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/database-migration.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/database-migration.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/database-migration.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
2 changes: 2 additions & 0 deletions fitnessdb-dbup/sql/04-add-temperature.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE dbo.TrainingSession
ADD Temperature DECIMAL(9,3) NULL
58 changes: 58 additions & 0 deletions fitnessdb-dbup/sql/05-stored-proc-update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
create or alter procedure web.get_trainingsessionsync
@json nvarchar(max)
as

declare @fromVersion int = json_value(@json, '$.fromVersion')

set xact_abort on
set transaction isolation level snapshot;
begin tran
declare @reason int

declare @curVer int = change_tracking_current_version();
declare @minVer int = change_tracking_min_valid_version(object_id('dbo.TrainingSession'));

if (@fromVersion = 0) begin
set @reason = 0 -- First Sync
end else if (@fromVersion < @minVer) begin
set @fromVersion = 0
set @reason = 1 -- fromVersion too old. New full sync needed
end

if (@fromVersion = 0)
begin
select
@curVer as 'Metadata.Sync.Version',
'Full' as 'Metadata.Sync.Type',
@reason as 'Metadata.Sync.ReasonCode',
[Data] = json_query((select Id, RecordedOn, [Type], Steps, Distance, Temperature from dbo.TrainingSession for json auto))
for
json path, without_array_wrapper
end else begin
select
@curVer as 'Metadata.Sync.Version',
'Diff' as 'Metadata.Sync.Type',
[Data] = json_query((
select
ct.SYS_CHANGE_OPERATION as '$operation',
ct.Id,
ts.RecordedOn,
ts.[Type],
ts.Steps,
ts.Distance,
ts.PostProcessedOn,
ts.AdjustedSteps,
ts.AdjustedDistance,
ts.Temperature
from
dbo.TrainingSession as ts
right outer join
changetable(changes dbo.TrainingSession, @fromVersion) as ct on ct.[Id] = ts.[id]
for
json path
))
for
json path, without_array_wrapper
end

commit tran
5 changes: 5 additions & 0 deletions fitnessdb-dbup/sql/06-temps-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into dbo.TrainingSession
(RecordedOn, [Type], Steps, Distance, Duration, Calories, Temperature)
values
('20200530 07:24:32 +08:00', 'Run', 4866, 4562, 30*60+18, 475, 60)
go