Single SQL query that finds out details of users who have visited ‘pricing’ + 1 other page, and have a session time > 45 seconds - sql-query-store

I have to assume the database table and then find out the details of users who have visited other pages and have session time > 45 seconds.
Table contains: (visitor_id, session_id, session_start, session_end, page_visited).
session_start and session_end have format YYYY-MM-DD HH:MI:SS.
page_visited has the pages visited by that user in that session.

Related

How should I extend the TTL of a document in Azure CosmosDB using the Python SDK?

I'm working with a Cosmos DB database with the SQL API. I have a container with TTL policy of 6 months. When a certain action is taken, my code receives an id and need to extend the deletion time for the item with that id in that container to now + 6 months. What is the recommended way to do this? An empty upsert?
I can assume the document exists.
The documents only need to be deleted in approximately six months. I'm not worried about exact timing.
I'm using the Python SDK. I looked through the documentation, but I could not find anything like an "extend" operation.
Should I not be leveraging the TTL? Should I be doing something else?
If you want to change to a different TTL on that particular item, just add or update the 'ttl' field to the desired number of seconds.
example copied straight from the docs:
item = container.read_item(
item='SO05',
partition_key='CO18009186470'
)
# Update ttl to 2 hours
item['ttl'] = 60 * 60 * 2
container.replace_item(
item='SO05',
body=item
)
basically it adds those seconds to the '_ts' field to set the time of deletion
Any update on the document resets the timestamp of that document (the _ts property).
The TTL basically acts based on that value.
So in your case, a simple Replace operation over that document would reset the timestamp so it would effectively be deleted 6 months after this last update.

How to implement pagination over a dynamic list of records

I have to implement pagination over a database of tickets in OPEN state with page size as 10 tickets using HTTP GET. The database of tickets however is not static and there can tickets that switch to CLOSED state from OPEN and new tickets in OPEN state that can get added to the database while the pagination is under way
In the current scenario consider the following cases
1) There are 100 tickets in OPEN state. When pagination starts we return 10 tickets and 10 pages as the total required pages. When the user navigates from page 1 to page 2 , assume that 50 more tickets in OPEN state are added. However these tickets don't occur within the first 10 pages and hence are never shown
2) There are 100 tickets in OPEN state. When pagination starts we return 10 tickets and 10 pages as the total required pages. When the user navigates from page 1 to page 2 , assume that 10 tickets switched to CLOSED state. So these tickets on page 1 are incorrect now and should not be shown.
What is the best approach to have pagination over a list of records which are dynamic?

Eventful API: Searching for events at a particular place

I'm searching for events at a particular place and also successfully retrieving all the events. But suppose I'm getting about 1500 events as "total_items" and the first page of response shows up the first 10 events.Then how could I reach to the remaining set of events, there isn't any "next page link".
And the most important question that are there any restrictions or upgradation plan for Eventful. Just because I was not able to find the required answers on their web portal. I'm posting it over here.
You are getting 10 events as default page size is 10 .If you want to change page size ,you can change it in your query.
http://api.eventful.com/rest/events/search?l=GREEN+BAY+WEST&page_size=100
In the above query it will return 100 events,you can get 100 events per page maximum.
If you want to go to next page,you can change page_number in your query.

Progress 4GL - Pagination

In PHP and MySQL I can do pagination of data like this:
select * from customers LIMIT $start, $limit;
The result will return me the page I'm requesting. Is it possible to do something like this using Progress 4GL?
I do not use -> select from customers
I use -> for each customers
But how can I set a limit and pages for that query search?
Example of the pagination:
I have 20.000 customers in my database. In each search I made, I want to separate the result. The limit I want to sent to the application is 100 rows of 1000. And when the user press page 2, it returns another 100 (but not the old 100) rows.
Does that make sense?
UPDATE
I'm using a technology from Adobe called Flex. The language Flex does not connect to the database directly, it depends on a back end language to do that.
So I'm using Flex and Progress 4GL. My flex application has a datagrid (like browser in 4GL) to show the data retrieved from my 4GL database.
The problem is that the database is huge, so I need to paginate the data. Each time the user clicks on another page, the Flex application has to communicate with Progress 4GL to retrieve the other page data. But, each click of the button is a different call so the Progress won't have any knowledge of the previous query.
How can I go from the 1st page to the 7th using a query?
Check this KB article on batching records to a .NET client
http://knowledgebase.progress.com/articles/Article/000033965?q=query+batch&l=en_US&c=Product_Group%3AOpenEdge&type=Article__kav&fs=Search&pn=1

Xpage Time zone return GMT format when set "Time zone" property as browser

I am working on create calendar view to show calendar entries from calendar database in browser/mobile using fullcalendar JQuery plug in.
(http://arshaw.com/fullcalendar/)
(http://keithstric.homeip.net/A55BAC/demo/fullCalendar.nsf)
The calendar view can be accessible by different region(different time zone).
User want to see calendar entries in their local time zone instead of server time zone.
So, xpage has feature to use browser time zone. Account to user time zone.
(http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPagesTimeZones.htm)
If enable Time zone as browser(user time zone), able to get browser time zone in server side using context.getTimeZone().
Programmatic ally, convert Date object stored in calendar entry to local time zone and send to fullcallendar plug in. Its works for me.
I like to display indication to user, what time zone they are.(e.g. CET, GMT, EST, IST)
My desired outcome:
your time zone is IST
My current outcome
Your time zone is GMT +5.30
My code like this:
"your time zone is "context.getTimeZone().getDisplayName()
how can i get time zone label instead of GMT format? else do we have any way to convert GMT to time zone label?

Resources