Web Log Sessions

Web Log Sessions

Simple
English

For this task, we have logs from various web sites. These logs contain information about user http and https requests. To analyse this data we need to parse and collect the information contained in these logs.

A log file is a text file, where each request is represented as a string. The strings are separated by a newline "\n". Requests contain a timestamp, username and URL. These fields are separated by ";;" .
Timestamps are represented in the following format:
YYYY-MM-DD-hh-mm-ss , where YYYY-MM-DD is the date, hh-mm-ss is the time.
Usernames contain only letters, digits and an underscore.
A URL is given in the normalized form (for example: http://checkio.org).
All fields are case-insensitive and must be converted in the lowercase.

You should collect information about user sessions from the given logs. A session is a sequence of the user requests at the same site (second-level domain), where each request is no more than 30 minutes older than the previous request from that user at the same site. We compare URL by second-level domain name, so admin.checkio.org and...

This log contains 4 sessions. The first three requests (1-3) are created by "Name" ("name") at the same site, checkio.org with no more than 30 minutes between "neighbour" requests. The second session contains two requests (4, 6) from "Name" at checkio.org (more than 30 minutes from 01:31:00 request). The next is the request (5) at example.com . The last session is the request (7) from "user2" at checkio.org .

The results should contain information about sessions in the next format:
username;;site;;duration;;quantity_of_requests
where each string is a session.

  • username is a username from logs.
  • site is a second-level domain.
  • duration is a time from first to last requests in seconds. The seconds are calculated inclusively. If there's only one request in the session, then it has 1 second duration. For example: two requests at 00:00:00 and 00:00:02 -- 3 seconds duration.
  • quantity_of_requests is a quantity of request in the session.
The sessions strings should be separated by newline ("\n") and sorted in the ascending order by next priorities: usernames, sites, durations and quantity_of_requests
The previous log text will be processed in:
name;;checkio.org;;661;;2
name;;checkio.org;;1861;;3
name;;example.com;;1;;1
user2;;checkio.org;;1;;1

Input: A log text, a multilines string (unicode).

Output: Sessions data, a multilines string.

Example:

checkio("""2013-01-01-01-00-00;;Name;;http://checkio.org/task
2013-01-01-01-02-00;;name;;http://checkio.org/task2
2013-01-01-01-31-00;;Name;;https://admin.checkio.org
2013-01-01-03-00-00;;Name;;http://www.checkio.org/profile
2013-01-01-03-00-01;;Name;;http://example.com
2013-02-03-04-00-00;;user2;;http://checkio.org/task
2013-01-01-03-11-00;;Name;;http://checkio.org/task""") ==
"""name;;checkio.org;;661;;2
name;;checkio.org;;1861;;3
name;;example.com;;1;;1
user2;;checkio.org;;1;;1"""

How it is used: This concept comes in handy when you need to gather aggregated data from the collected log file. This will help you to get information about user session for the various sites. You can improve your code here for more complex cases.

You should be an authorized user in order to see the full description and start solving this mission.
45
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission