ビジネス ロジックを Azure レイヤーに実装しようとしていますが、この node.js スタイルのスクリプトを Insert で把握していません。
これで機能するT-SQLがあります
declare @latitude decimal(23,20)
declare @longitude decimal(23,20)
declare @timeStamp datetime
set @latitude = 37.7858340000000012537
set @longitude = -122.4064170000000046911
set @timeStamp = '2012-12-25 02:58:23'
select longitude, latitude, userid
from blah.actions ba
where
(
datediff(second, ba.TimeStamp, @timeStamp) < 5 and
(ba.longitude - 0.0001 <= @longitude and ba.longitude + 0.0001 >= @longitude) and
(ba.latitude - 0.0001 <= latitude and ba.latitude + 0.0001 >= latitude)
)
問題は、関数を使用して、挿入時に Azure スクリプト内のテーブル クエリをフィルター処理するにはどうすればよいかということです。
ということで、もう少し作業。関数を使用してフィルター処理する方法を理解しました (ただし、Azure スクリプトをデバッグする方法にはまだ苦労しています)。私の挿入物には次のものがあります。「内部サーバーエラー」が表示されなくなったため、「機能」していますが、結果をログに記録したり表示したりする方法がわかりません(この Azure に関するヒントは大歓迎です)。このアプリケーションでどれだけ多くの作業を行う必要があるかを理解し始めています。
function dateDiff(date1, date2)
{
return date1.getTime() - date2.getTime() / 1000;
}
function insert(item, user, request) {
request.execute();
var actionsTable = tables.getTable('BlahActions');
actionsTable.where(function(currentLat, currentLon, currentTime)
{
return (this.Latitude - 0.0001 <= currentLat && this.Latitude + 0.0001 >= currentLat) &&
(this.Longitude - 0.0001 <= currentLon && this.Longitude + 0.0001 >= currentLon) &&
(this.TimeStamp == currentTime);
//(dateDiff(this.TimeStamp, currentTime) <= 5);
}, item.Latitude, item.Longitude, item.TimeStamp)
.read(
{
success:function(results)
{
}
});
}
上記のスクリプトの問題は、getTime() を使用すると Azure が吐き出すことです。同じ緯度と経度に近く、過去 X 秒以内に発生したすべてのエントリを取得する必要があります (はい、本質的に「バンプ」を再発明しています)。これは私が現在立ち往生しているところです。この部分を通過した場合は更新します。