For a (even more) Web 2.0 like look-and-feel in your APEX application you can define a dynamic region 'My Favorite Tasks', that shows links to the pages you visit most frequently.
For these favorites we can query the APEX repository. Follow these steps to get this thing working:
For these favorites we can query the APEX repository. Follow these steps to get this thing working:
- Enable logging on Application Level. Enabling the logging will result in records in the view apex_workspace_activity_log.
- Create a Report Page with a region based on a SQL Query.
- Enter the query to show the links for the three most visited pages:
select htf.anchor( 'f?p='||:APP_ID||':'||page_id||':'||:APP_SESSIONIn a next post I will show how you can embed this report page in any other page in your application.
, page_name ) Task
from
(
select page_name
, page_id
, count(*)
from apex_workspace_activity_log
where application_id = :APP_ID
and apex_user = :APP_USER
and page_id <> :APP_PAGE_ID
group by page_name, page_id
order by 3 desc
)
where rownum <= 3
Comments
This can also be done using apex view apex_activity_log instead of wwv_flow_activity_log. Using apex_activity_log you would not need steps 1 and 2.
Thanks,
Todd
Stew
It looks like the better bet would be to use the apex_workspace_activity_log table, since it's already granted to the workspace.
I'd use an inner query like:
SELECT *
FROM (SELECT page_id, page_name, MIN(seconds_ago) last_ones
FROM apex_workspace_activity_log
WHERE application_id = :APP_ID
AND page_id <> 101 -- Login page
AND userid = :APP_USER
GROUP BY page_id, page_name)
WHERE rownum <= 3
ORDER BY 3;
Or maybe I'm missing something?
A combination of both suggestions seems to result in the best query:
- use apex_workspace_activity_log instead of the wwv_flow_activity_log (although the apex_.. view only contains data of the last 14 days).
- I think I don't have to exclude the login page, as there is no known user at the time that page pops up.
- the ORDER_BY should be inside the inline view, otherwise you don't get the Top-3.
- use APEX_USER instead of USERID
- exclude the current page from the query by filtering on :APP_PAGE_ID
I updated my post with your suggestions!
Thanks,
Roel
I really like this.
One thing I found though was that my development team and I use some quite obscure 'Developer' coded page titles (e.g. Developer initials, module reference etc) and the Page Names are set to something more user friendly, after all, the Page Name is what the user sees at the top of their web browser.
A join in the query, as shown below, gave us a more user friendly result. Of course, if your page names and titles are the same then you needn't bother.
Just my thoughts.
As I said, nice post.
select htf.anchor( 'f?p='||:APP_ID||':'||page_id||':'||:APP_SESSION
, page_title ) "Favourite Pages"
from
(
select aap.page_title
, awal.page_id
, count(awal.page_id)
from apex_workspace_activity_log awal
join APEX_APPLICATION_PAGES aap on aap.application_id = awal.application_id and aap.page_id = awal.page_id
where awal.application_id = :APP_ID
and awal.apex_user = :APP_USER
and awal.page_id <> :APP_PAGE_ID
group by aap.page_title, awal.page_id
order by 3 desc
)
where rownum <= 3
select htf.anchor( 'f?p='||:APP_ID||':'||page_id||':'||:APP_SESSION, page_name ) Task
from (select act.page_name
, act.page_id
, count(*) "load_count"
from APEX_APPLICATION_TABS tab
join APEX_WORKSPACE_ACTIVITY_LOG act on tab.tab_page = act.page_id
where act.application_id = :APP_ID
and act.apex_user = :APP_USER
and act.page_id <> :APP_PAGE_ID
group by act.page_name, act.page_id
order by 3 desc)
where rownum <= 10;
Greets,
Maurice Kremer