Skip to content

Commit 85e3c21

Browse files
author
scoriani
committed
add temperature
1 parent b5e8846 commit 85e3c21

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

fitnessdb-dbup/.vscode/launch.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/database-migration.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}",
16+
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17+
"console": "internalConsole",
18+
"stopAtEntry": false
19+
},
20+
{
21+
"name": ".NET Core Attach",
22+
"type": "coreclr",
23+
"request": "attach",
24+
"processId": "${command:pickProcess}"
25+
}
26+
]
27+
}

fitnessdb-dbup/.vscode/tasks.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/database-migration.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/database-migration.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/database-migration.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE dbo.TrainingSession
2+
ADD Temperature DECIMAL(9,3) NULL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
create or alter procedure web.get_trainingsessionsync
2+
@json nvarchar(max)
3+
as
4+
5+
declare @fromVersion int = json_value(@json, '$.fromVersion')
6+
7+
set xact_abort on
8+
set transaction isolation level snapshot;
9+
begin tran
10+
declare @reason int
11+
12+
declare @curVer int = change_tracking_current_version();
13+
declare @minVer int = change_tracking_min_valid_version(object_id('dbo.TrainingSession'));
14+
15+
if (@fromVersion = 0) begin
16+
set @reason = 0 -- First Sync
17+
end else if (@fromVersion < @minVer) begin
18+
set @fromVersion = 0
19+
set @reason = 1 -- fromVersion too old. New full sync needed
20+
end
21+
22+
if (@fromVersion = 0)
23+
begin
24+
select
25+
@curVer as 'Metadata.Sync.Version',
26+
'Full' as 'Metadata.Sync.Type',
27+
@reason as 'Metadata.Sync.ReasonCode',
28+
[Data] = json_query((select Id, RecordedOn, [Type], Steps, Distance, Temperature from dbo.TrainingSession for json auto))
29+
for
30+
json path, without_array_wrapper
31+
end else begin
32+
select
33+
@curVer as 'Metadata.Sync.Version',
34+
'Diff' as 'Metadata.Sync.Type',
35+
[Data] = json_query((
36+
select
37+
ct.SYS_CHANGE_OPERATION as '$operation',
38+
ct.Id,
39+
ts.RecordedOn,
40+
ts.[Type],
41+
ts.Steps,
42+
ts.Distance,
43+
ts.PostProcessedOn,
44+
ts.AdjustedSteps,
45+
ts.AdjustedDistance,
46+
ts.Temperature
47+
from
48+
dbo.TrainingSession as ts
49+
right outer join
50+
changetable(changes dbo.TrainingSession, @fromVersion) as ct on ct.[Id] = ts.[id]
51+
for
52+
json path
53+
))
54+
for
55+
json path, without_array_wrapper
56+
end
57+
58+
commit tran

fitnessdb-dbup/sql/06-temps-data.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
insert into dbo.TrainingSession
2+
(RecordedOn, [Type], Steps, Distance, Duration, Calories, Temperature)
3+
values
4+
('20200530 07:24:32 +08:00', 'Run', 4866, 4562, 30*60+18, 475, 60)
5+
go

0 commit comments

Comments
 (0)