Error is: ENOENT: no such file or directory, stat 'D:\MyPrj\App_Resources\Android' - angular2-nativescript

i'm get the following output when run tns run android in my project:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* You are using the Legacy Workflow. *
* *
* With the upcoming NativeScript 6.0 the Webpack workflow will become the only way of building apps. *
* More info about the reasons for this change and how to migrate your project can be found in the link below: *
* https://www.nativescript.org/blog/the-future-of-building-nativescript-apps *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Unable to apply changes on device: emulator-5554. Error is: ENOENT: no such file or directory, stat 'D:\MyPrj\App_Resources\Android'.
Stopping tsc watch
Stopping webpack watch
tns --version gives me 5.4.2.
also I'm trying to upgrade all modules. even installed nativescript-dev-webpack
but the output is same:
ERROR in [copy-webpack-plugin] unable to locate 'D:\MyPrj\App_Resources/Android' at 'D:\MyPrj\App_Resources/Android'
regards

Update your nativescript cli with latest version using npm i -g nativescript and create a new project using nativescript sidekick and try to again run the project.

Related

reuse query calculations with Postgres

I have this (beginner) query:
let getCandlesSQL =
$"SELECT
date_trunc('minute', ts) ts,
instrument,
MAX(price) high,
MIN(price) low,
(SUM(price * price * quantity) / SUM(price * quantity)) midpoint,
SUM(price * quantity) volume,
(SUM(direction * price * quantity) / SUM(price * quantity)) direction
FROM {tableTradesName}
WHERE instrument = '{instrument.Ticker}' AND ts BETWEEN '{fromTime}' AND '{toTime}'
GROUP BY date_trunc('minute', ts), instrument
ORDER BY ts
LIMIT 4500"
I rebuild the string with internal variables at every call, so I don't need to use the SQL variable mechanism.
There are a few calculations that are done multiple times, for example 'price * quantity' is done many times.
Is there a way to write the query to do it once and then re-use it?

PostgreSQL column does not exist when sub select

I have a table called user, and I need to get another users in an expecific distance range and the distance between them. My query is this:
select ( 6371 * acos(
cos( radians(users.latitude) )
* cos( radians(-22.9035) )
* cos( radians(-43.2096) - radians(users.longitude) )
+ sin( radians(users.latitude) )
* sin( radians(-22.9035) )
)
) as distance, users from users where users.id != 41 and distance > 50
I need to recover the user list and the distance, but the "as distance" is not working:
ERROR: column "distance" does not exist.
I tried with:
with distance as (
select ( 6371 * acos(
cos( radians(users.latitude) )
* cos( radians(-22.9035) )
* cos( radians(-43.2096) - radians(users.longitude) )
+ sin( radians(users.latitude) )
* sin( radians(-22.9035) )
)
) from users
)
select * from users where users.id != 41 and distance > 50
However, the error remains the same.
In Postgres, you cannot use column aliases in a where clause. That's why your first query does not work.
Your second query using a CTE can be made to work, but distance is a virtual table, not a column. Join with it.
with users_distance as (
select
id,
( 6371 * acos(
cos( radians(users.latitude) )
* cos( radians(-22.9035) )
* cos( radians(-43.2096) - radians(users.longitude) )
+ sin( radians(users.latitude) )
* sin( radians(-22.9035) )
)
) as distance
from users
)
select *
from users
join users_distance ud on users.id = ud.id
where users.id != 41 and ud.distance > 50
If you do this a lot, consider adding a generated column to the table so you don't have to recalculated it all the time.
alter table users add column distance numeric
generated always as (
6371 * acos(
cos( radians(users.latitude) )
* cos( radians(-22.9035) )
* cos( radians(-43.2096) - radians(users.longitude) )
+ sin( radians(users.latitude) )
* sin( radians(-22.9035) )
)
) stored
Try it
Finally, rather than doing these calculations yourself, consider using the very powerful PostGIS extension.

How to factor this postgis query with subquery?

I have a query to found POIs around trace :
SELECT
ptb.* AS pois
FROM traces tr, pois pta, pois ptb
WHERE tr.id = #{trace.id}
AND pta.id = #{poi.id}
AND ST_DWithin(
ST_LineSubstring(
tr.path,
ST_LineLocatePoint(tr.path, pta.lonlat::geometry) + (#{dist} * 1000) / ST_Length(tr.path, false),
ST_LineLocatePoint(tr.path, pta.lonlat::geometry) + (#{end_point} * 1000) / ST_Length(tr.path, false)
)::geography,
ptb.lonlat::geography,
4000)
How can I use subquery for :
ST_LineLocatePoint(tr.path, pta.lonlat::geometry)
ST_Length(tr.path, false)
EDIT :
WITH RECURSIVE locate_point_a AS (
select ST_LineLocatePoint(tr.path, pta.lonlat::geometry) AS locate_point_a
FROM traces tr, pois pta
WHERE tr.id = 2
AND pta.id = 2
)
SELECT
ptb.* AS pois
FROM traces tr, pois pta, pois ptb, locate_point_a
WHERE tr.id = 2
AND pta.id = 2
AND ST_DWithin(
ST_LineSubstring(
tr.path,
locate_point_a + (25 * 1000) / ST_Length(tr.path, false),
locate_point_a + (250 * 1000) / ST_Length(tr.path, false)
)::geography,
ptb.lonlat::geography,
4000)
SQL
This should do the same (but I do not understand the logic, TBH):
SELECT
ptb.* -- AS pois
FROM pois ptb
WHERE EXISTS (
SELECT *
FROM traces tr
JOIN pois pta ON ST_DWithin(
ST_LineSubstring( tr.path
, ST_LineLocatePoint(tr.path, pta.lonlat::geometry) + (#{dist} * 1000) / ST_Length(tr.path, false)
, ST_LineLocatePoint(tr.path, pta.lonlat::geometry) + (#{end_point} * 1000) / ST_Length(tr.path, false)
)::geography
, ptb.lonlat::geography
, 4000
)
WHERE tr.id = #{trace.id}
AND pta.id = #{poi.id}
;

How to use FOREACH to query multiple times using the values in an aray

I want to run a query and get the rows by iterating over an array using FOREACH loop in postgresql.
I have tried using the FOREACH loop as explained in the docs but it returns an error "cannot use RETURN QUERY in a non-SETOF function"
DO
$do$
DECLARE
a integer[] := array[1,2,3];
i integer;
begin
foreach i IN ARRAY a
LOOP
RETURN QUERY
select
models.sku,
(sum(models.unitretailprice) * sum(coefficients.unit_retail_price)) +
(sum(models.flag::int) * sum(coefficients.flag::int)) +
(sum(models.mc_baseline) * sum(coefficients.mc_baseline)) +
(sum(models.mc_day_avg) * sum(coefficients.mc_day_avg)) +
(sum(models.mc_day_normal) * sum(coefficients.mc_day_normal)) +
(sum(models.mc_week_avg) * sum(coefficients.mc_week_avg)) +
(sum(models.mc_week_normal) * sum(coefficients.mc_week_normal)) +
(sum(models.sku_day_avg) * sum(coefficients.sku_day_avg)) +
(sum(models.sku_month_avg) * sum(coefficients.sku_month_avg)) +
(sum(models.sku_month_normal)* sum(coefficients.sku_month_normal)) +
(sum(models.sku_moving_avg) * sum(coefficients.sku_moving_avg)) +
(sum(models.sku_week_avg) * sum(coefficients.sku_week_avg)) +
(sum(models.sku_week_normal)* sum(coefficients.sku_week_normal)) as baseline,
(i * sum(coefficients.f)) +
(5 * sum(coefficients.p)) +
(0 * sum(coefficients.a)) as promoIncremental,
(sum(models.basket_dollar_off) * sum(coefficients.basket_dollar_off)) +
(sum(models.basket_per_off) * sum(coefficients.basket_per_off)) +
(sum(models.category_dollar_off) * sum(coefficients.category_dollar_off)) +
(sum(models.category_per_off) * sum(coefficients.category_per_off)) +
(sum(models.disc_per) * sum(coefficients.disc_per)) as couponIncremnetal
from
models join coefficients
on
models.sku = coefficients.sku
and
models.si_type = coefficients.si_type
and
models.model_type = coefficients.model_type
where
coefficients.sku in ('12841276', '11873916') and coefficients.shop_descr = 'Papercrafting Technology'
group by models.sku ;
END LOOP;
end
$do$
You can cross join a CTE with the factors to a derived table that is made of your current table.
WITH a (i)
AS
(
VALUES (1),
(2),
(3)
)
SELECT ...
a.i * x.sum_f + 5 * x.sum_p promoincremental,
...
FROM a
CROSS JOIN (SELECT ...
sum(coefficients.f) sum_f,
sum(coefficients.p) sum_p,
...
FROM ...) x;

Column in having clause does not exist issue in Doctrine and pgadmin

I am running a query in pgadmin but facing issue column distance does not exist
select f.title, f.longitude, f.latitude, (3959 * cos(cos(radians('52.512452')) * cos(radians(latitude)) * cos(radians(longitude) - radians('13.390931')) + sin(radians('52.512452')) * sin(radians(latitude)))) AS distance from fitness_studio f having distance<1 order by distance desc
Thanks in advance for any help.
Regards,
Aisha
As far as I know postgresql has no way to directly use an alias column in where clause. So you should either try to duplicate the logic:
SELECT
f.title,
f.longitude,
f.latitude,
(3959 * cos(cos(radians('52.512452')) * cos(radians(latitude)) * cos(radians(longitude)
- radians('13.390931')) + sin(radians('52.512452')) * sin(radians(latitude)))) AS distance
FROM fitness_studio f
WHERE (3959 * cos(cos(radians('52.512452')) * cos(radians(latitude)) *
cos(radians(longitude) - radians('13.390931')) +
sin(radians('52.512452')) * sin(radians(latitude)))) < 1
ORDER BY distance DESC
either to use a subquery:
WITH container AS (
SELECT
f.title,
f.longitude,
f.latitude,
(3959 * cos(cos(radians('52.512452')) * cos(radians(latitude)) *
cos(radians(longitude) - radians('13.390931')) +
sin(radians('52.512452')) * sin(radians(latitude)))) AS distance
FROM fitness_studio f)
SELECT *
FROM container
WHERE distance < 1
ORDER BY distance DESC
Please keep in mind that using such subquery may negatively affect execution plan and when your table is large enough execution speed becomes more important than query awkwardness.
PS: Note that ORDER BY may correctly get alias as parameter. Suppose it's cause ORDER BY doesn't affect selected rows, it just rotates them. Same picture with GROUP BY