Capybara: How to select drop down value from below html - capybara

Capybara: How to select drop down value from below html
Month
01
02
03
04
05
06
07
08
09
10
11
12

The from option to select takes either the id, name, placeholder, or the text of an associated label element of the select element. "data-reactid" is none of those. Given the html you have put in the comments (please edit your question and add it there) you could just do
select("01") # assumes there are no other select boxes with that option on the page
or you could do
find('select[data-reactid=".0.0.1.1.2.1.$0.0.2.0.1"]').select("01")
which is just short for
find('select[data-reactid=".0.0.1.1.2.1.$0.0.2.0.1"]').find(:option, "01").select_option
Note: within '#.0.0.1.1.2.1.$0.0.2.0.1' isn't going to do anything since within takes a css selector and none of your elements have the id '#.0.0.1.1.2.1.$0.0.2.0.1' ( a data-reactid is not an id ) . On top of that the selector as written is invalid and would probably need to be within '#\.0\.0\.1\.1\.2\.1\.\$0\.0\.2\.0\.1' if an element with that id existed

Related

Google Sheets - transpose irregular column data in groups into rows

Much like the problem with the transposing of data in transpose column data I am stuck trying to transpose a set of data with multiple variables. The biggest issue I face is trying to remove useless data. Table 1 is how the data is received
Column N
Sep 07 2022
Alert
Something went wrong
fish company
70000123456
1234567
231.03
View Details
Sep 07 2022
---
meat company
70000987654
688773
View Details
Sep 07 2022
Success
produce company
70000192837
View Details
Table 2 is the desired output
Column A
Column B
Column C
Column D
Column E
date
vendor
po
Invoice
cost
Sep 07 2022
fish company
70000123456
1234567
231.03
Sep 08 2022
meat company
70000987654
D688773B
Sep 07 2022
produce company
70000192837
I was unable to trim cells Alert and Something went wrong due to nesting errors.
REDUCE the array to the string, joined by delimiters. If the value is a date, join by 🍚, else if it's a value of interest determined by REGEXMATCH, join by 🐇. From the created string, split by the row delimiter 🍚, TRANSPOSE and SPLIT by the column delimiter 🐇
=ARRAYFORMULA(SPLIT(TRANSPOSE(SPLIT(REDUCE(,A2:A20,LAMBDA(a,c,IFS(ISDATE(c),a&"🍚"&TO_TEXT(c),REGEXMATCH(TO_TEXT(c),".*company|70{5}\d+|\d+"),a&"🐇"&c,TRUE,a))),"🍚")),"🐇"))
Sep 07 2022
fish company
70000123456
1234567
231.03
Sep 07 2022
meat company
70000987654
688773
Sep 07 2022
produce company
70000192837
If you don't care about dragging formulas, you might be able to use something like the following steps I did:
Pasted your data starting in cell A2.
Put a formula for to identify dates to the right of your data starting in cell B2: =N(B1)+if(ISDATE(A2),1,0) (NOTE this formula isn't dynamic)
Create a unique list filter list cell D1: =UNIQUE(Filter(B:B,B:B<>""))
Used formula to parse out data next to unique list (so starting in E2): =Transpose(FILTER(if(A:A="Alert",,A:A),(B:B=D2)*(A:A<>"ALert")*(A:A<>"Something Went Wrong")*(A:A<>"View Details")))
As you can see in part 4, I tried to strip out members that you flagged as irrelevant. I'm not sure what other rules you have.
There's probably a way to make steps 2 and 4 dynamic spill formulas, but that's all I have time for.
Ended up with this (yellow cells have relevant formula).

looking for way show all unique code based on day index

I want to show how many unique characters on that day based on a day in one column, for example, on day 01 we have code DC13850-DC13873 , when I input the formula with day 01 I want all codes in that day to show, and also when I change the day all the code also change based on the selected day
:
day Code
01 DC13850
01 DC13851
01 DC13852
02 DC13853
02 DC13854
02 DC13855
03 DC13856
03 DC13857
03 DC13858
I've been struggling with it, can anyone help me?
try:
=UNIQUE(FILTER(E:E; D:D="01"))

How is user_first_touch_timestamp different from first_open_time?

Does "first" mean first in this run of the app (until the app terminates and restarts), or first across runs?
I thought that these fields will have only one value, but they often have two. When I run this query:
SELECT
user_pseudo_id,
COUNT(*) AS the_count
FROM (
SELECT
DISTINCT user_pseudo_id,
user_first_touch_timestamp AS user_first_touch_timestamp
FROM
`noctacam.<my project>.events*`
WHERE
app_info.id = "<my bundle ID>"
ORDER BY
user_pseudo_id)
GROUP BY
user_pseudo_id
ORDER BY
the_count DESC
I find that 0.6% of my users have two different values for user_first_touch_timestamp. Is this a bug in Firebase?
Likewise for first_open_time:
SELECT
user_pseudo_id,
COUNT(*) AS the_count
FROM (
SELECT
DISTINCT user_pseudo_id,
user_properties.value.int_value AS first_open_time
FROM
`noctacam.<my project>.events*`,
UNNEST(user_properties) AS user_properties
WHERE
app_info.id = "<my bundle ID>"
AND user_properties.key = "first_open_time"
ORDER BY
user_pseudo_id)
GROUP BY
user_pseudo_id
ORDER BY
the_count DESC
Exactly the same 0.6% of users have two different values for this field, too.
References:
https://support.google.com/firebase/answer/7029846?hl=en
https://support.google.com/firebase/answer/6317486?hl=en
I started wondering about the difference in these 2 params too and found this difference.
From User Properties:
First Open Time - The time (in milliseconds, UTC) at which the user first opened the app, rounded up to the next hour.
From BigQuery Export Schema:
user_first_touch_timestamp - The time (in microseconds) at which the user first opened the app.
In my case, the rounding was the difference. I envision that Firebase needed to have first_open_time as a User Property for some reason so they just rounded and copied user_first_touch_timestamp.
I know it still doesn't answer your whole question and doesn't explain why 0.6% of your users have 2 different values. I still thought that this may help someone here.
There is also a difference in the description of the two parameters:
first_open = "the first time a user launches an app after installing or re-installing it"
whereas first_touch_timestamp has no mention of the value updating for re-installs. It is likely your 0.6% difference is users who have re-installed the app.
The difference is in the accuracy of the data:
while User_first_touch_timestamp gives the exact time,
First_open_time gives the rounded-up time.
Take a look at the following examples:
User 1:
User_first_touch_timestamp: 1670263710266000
Mon Dec 05 2022 20:08:30 GMT+0200
First_open_time : 1670266800000
Mon Dec 05 2022 21:00:00 GMT+0200
User 2:
User_first_touch_timestamp: 1670248060903000
Mon Dec 05 2022 15:47:40 GMT+0200
First_open_time: 1670248800000
Mon Dec 05 2022 16:00:00 GMT+0200

Testing a list is sorted in the correct order capybara

I'm trying to write some tests in capybara that will test a list of dates are sorted correctly. For example I have a list of dates Wed 27 Jun 12, Mon 13 Aug 12, Thu 31 May 12 and when I click on the button it will rearrange the dates starting from the earliest ie: Thu 31 May 12, Wed 27 Jun 12, 13 Aug 12.
Is there any way in capybara that you can write such tests.
Normally I would use methods like page.find etc but those methods will just find the dates and not tell you if they have been sorted in the correct order.
You need to use the :nth-child css selector.
Lets say your list of dates are in a <ul> with the id #dates, you could test order with:
page.should have_selector("ul#dates li:nth-child(1)", content: #date1.content)
page.should have_selector("ul#dates li:nth-child(2)", content: #date2.content)
The first value passed into have_selector() is your selector, the second (in this example) is the content you expect. You're not limited to passing just content for example if each date linked to the Date#show action you could add url: date_path(#date).

Ruby on rails active record multiple group record to calculate numbers

I want to calculate number of employee who has commanded to shoot on every day.
Shoot.where("command_type = ?", "shoot").group("DATE(created_at)").group("employee_number").order("DATE(created_at)").count
It will give me a output like
{[Wed, 03 Aug 2011, "7838744451"]=>2, [Wed, 03 Aug 2011, "8055898284"]=>11,[Fri, 05 Aug 2011, "9702553828"]=>1, [Fri, 05 Aug 2011, "9717466677"]=>1,[Fri, 05 Aug 2011, "8055898284"]=>1,[Wed, 06 Aug 2011, "8055898284"]=>5
I want to have an array something like:-
[2,0,3,1] // zero is for the dates when no record is there for that date. and number in the array is that number of the employees that has been ordered to shoot.
For example from array: 2 employee were ordered to shoot on Wed, 3rd.
0 employee were ordered to shoot on 4th and so on...
Also: How can i calculate that a how many times all employees were commanded to shoot in a week/month. Basically 100 employee were ordered to shoot 1st week. 120 employees were order to shoot 2nd week and so on 1st month and 2nd month..
The command you are using returns the daily count by employee. If you want to get the daily count across employees, remove the 2nd group call.
# return [2,3,1]
Shoot.where(:command_type => shoot").group("DATE(created_at)").values
If you want to fill the missing date values, you can use this function:
class Shoot
def self.daily_count_by_type(type = "shoot", range=7.days)
counts = Shoot.where(:command_type => type).group("DATE(created_at)").
count("DISTINCT employee_id")
(range.ago.to_date..Date.today).map {|d| counts[d.to_s] || 0}
end
end
Now
Shoot.daily_count_by_type # for type `shoot`, last 7 days
Shoot.daily_count_by_type("shoot") # for type `shoot`, last 7 days
Shoot.daily_count_by_type("eat", 14.days) # for type `eat`, last 14 days
Shoot.daily_count_by_type("leave") # for type `leave`, last 14 days
Make sure you add an index on DATE(CREATED_AT) to improve the performance.
Edit 1
Based on the comment you need to COUNT the distinct values. I have updated the answer accordingly.

Resources