feature/analysis-form #10
7
app/static/common.js
Normal file
7
app/static/common.js
Normal file
@@ -0,0 +1,7 @@
|
||||
function checkAllCheckboxes(tableId, checkAllCheckboxId) {
|
||||
const table = document.getElementById(tableId);
|
||||
const checkboxes = table.querySelectorAll('input[type="checkbox"]');
|
||||
const checkAllCheckbox = document.getElementById(checkAllCheckboxId);
|
||||
|
||||
checkboxes.forEach(checkbox => checkbox.checked = checkAllCheckbox.checked);
|
||||
}
|
||||
@@ -93,12 +93,4 @@ function sortTable(columnIndex, tableId) {
|
||||
|
||||
// Reinsert sorted rows
|
||||
rows.forEach(row => tbody.appendChild(row));
|
||||
}
|
||||
|
||||
function checkAllCheckboxes(tableId, checkAllCheckboxId) {
|
||||
const table = document.getElementById(tableId);
|
||||
const checkboxes = table.querySelectorAll('input[name="fileCheckbox"]');
|
||||
const checkAllCheckbox = document.getElementById(checkAllCheckboxId);
|
||||
|
||||
checkboxes.forEach(checkbox => checkbox.checked = checkAllCheckbox.checked);
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
<!-- Analysis Selection Table -->
|
||||
<label for="analyses" class="form-label">Select Analyses:</label>
|
||||
<table class="table table-bordered table-striped">
|
||||
<table id="analysesTable" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Select</th>
|
||||
<th width="2%"><input type="checkbox" id="checkAllAnalyses" class="form-check-input" onclick="checkAllCheckboxes('analysesTable', 'checkAllAnalyses')"></th>
|
||||
<th>Analysis Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<table id="dataFilesTable" class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="2%"><input type="checkbox" id="checkAllData" onclick="checkAllCheckboxes('dataFilesTable', 'checkAllData')"></th>
|
||||
<th width="2%"><input type="checkbox" class="form-check-input" id="checkAllData" onclick="checkAllCheckboxes('dataFilesTable', 'checkAllData')"></th>
|
||||
<th onclick="sortTable(1, 'dataFilesTable')">File Name</th>
|
||||
<th onclick="sortTable(2, 'dataFilesTable')">Last Modified</th>
|
||||
<th onclick="sortTable(3, 'dataFilesTable')">Created</th>
|
||||
@@ -30,7 +30,7 @@
|
||||
<tbody>
|
||||
{% for file in files.data %}
|
||||
<tr>
|
||||
<td><input type="checkbox" name="fileCheckbox" value="{{ url_for('download_data_file', filename=file.name_display) }}"{{ ' disabled' if file.active }}></td>
|
||||
<td><input type="checkbox" name="fileCheckbox" class="form-check-input" value="{{ url_for('download_data_file', filename=file.name_display) }}"{{ ' disabled' if file.active }}></td>
|
||||
<td><a href="{{ url_for('download_data_file', filename=file.name_display) }}" target="_blank">{{ file.name_display }}</a></td>
|
||||
<td>{{ file.last_modified | datetimeformat }}</td>
|
||||
<td>{{ file.created | datetimeformat }}</td>
|
||||
@@ -79,7 +79,7 @@
|
||||
<tbody>
|
||||
{% for file in files.log %}
|
||||
<tr>
|
||||
<td><input type="checkbox" name="fileCheckbox" value="{{ url_for('download_log_file', filename=file.name_display) }}"{{ ' disabled' if file.active }}></td>
|
||||
<td><input type="checkbox" name="fileCheckbox" class="form-check-input" value="{{ url_for('download_log_file', filename=file.name_display) }}"{{ ' disabled' if file.active }}></td>
|
||||
<td><a href="{{ url_for('download_log_file', filename=file.name_display) }}" target="_blank">{{ file.name_display }}</a></td>
|
||||
<td>{{ file.last_modified | datetimeformat }}</td>
|
||||
<td>{{ file.created | datetimeformat }}</td>
|
||||
@@ -98,8 +98,5 @@
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{% block scripts %}
|
||||
{{ bootstrap.load_js() }}
|
||||
<script src="{{url_for('.static', filename='download_results.js')}}"></script>
|
||||
{% endblock %}
|
||||
{% endblock content %}
|
||||
@@ -1,2 +1,3 @@
|
||||
{{ bootstrap.load_js() }}
|
||||
<script src="{{url_for('static', filename='color_mode.js')}}"></script>
|
||||
<script src="{{url_for('static', filename='color_mode.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='common.js') }}"></script>
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"execution_count": 69,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -144,6 +144,7 @@
|
||||
" <th>timestamp</th>\n",
|
||||
" <th>prev_timestamp</th>\n",
|
||||
" <th>was_active</th>\n",
|
||||
" <th>hour</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
@@ -156,6 +157,7 @@
|
||||
" <td>2025-02-08 18:09:41.867984056</td>\n",
|
||||
" <td>NaT</td>\n",
|
||||
" <td>False</td>\n",
|
||||
" <td>18</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
@@ -166,6 +168,7 @@
|
||||
" <td>2025-02-08 18:09:42.427846909</td>\n",
|
||||
" <td>NaT</td>\n",
|
||||
" <td>False</td>\n",
|
||||
" <td>18</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
@@ -176,6 +179,7 @@
|
||||
" <td>2025-02-08 18:09:42.823201895</td>\n",
|
||||
" <td>NaT</td>\n",
|
||||
" <td>False</td>\n",
|
||||
" <td>18</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
@@ -186,6 +190,7 @@
|
||||
" <td>2025-02-08 18:09:43.179914951</td>\n",
|
||||
" <td>NaT</td>\n",
|
||||
" <td>False</td>\n",
|
||||
" <td>18</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
@@ -196,6 +201,7 @@
|
||||
" <td>2025-02-08 18:09:43.434650898</td>\n",
|
||||
" <td>NaT</td>\n",
|
||||
" <td>False</td>\n",
|
||||
" <td>18</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
@@ -209,15 +215,15 @@
|
||||
"3 2208384 Volfywolf 2025-02-06 23:57:24 Okay \n",
|
||||
"4 2521738 LordGrim69 2025-02-06 06:33:40 Okay \n",
|
||||
"\n",
|
||||
" timestamp prev_timestamp was_active \n",
|
||||
"0 2025-02-08 18:09:41.867984056 NaT False \n",
|
||||
"1 2025-02-08 18:09:42.427846909 NaT False \n",
|
||||
"2 2025-02-08 18:09:42.823201895 NaT False \n",
|
||||
"3 2025-02-08 18:09:43.179914951 NaT False \n",
|
||||
"4 2025-02-08 18:09:43.434650898 NaT False "
|
||||
" timestamp prev_timestamp was_active hour \n",
|
||||
"0 2025-02-08 18:09:41.867984056 NaT False 18 \n",
|
||||
"1 2025-02-08 18:09:42.427846909 NaT False 18 \n",
|
||||
"2 2025-02-08 18:09:42.823201895 NaT False 18 \n",
|
||||
"3 2025-02-08 18:09:43.179914951 NaT False 18 \n",
|
||||
"4 2025-02-08 18:09:43.434650898 NaT False 18 "
|
||||
]
|
||||
},
|
||||
"execution_count": 61,
|
||||
"execution_count": 69,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -229,6 +235,7 @@
|
||||
" df[\"prev_timestamp\"] = df.groupby(\"user_id\")[\"timestamp\"].shift(1)\n",
|
||||
" df[\"was_active\"] = (df[\"timestamp\"] - df[\"last_action\"]) <= pd.Timedelta(seconds=60)\n",
|
||||
" df[\"was_active\"] = df[\"was_active\"].fillna(False)\n",
|
||||
" df['hour'] = df['timestamp'].dt.hour\n",
|
||||
" return df\n",
|
||||
"\n",
|
||||
"df = prepare_data(df)\n",
|
||||
@@ -269,7 +276,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 63,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -284,9 +291,6 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Extract the hour from the 'timestamp' column\n",
|
||||
"df['hour'] = df['timestamp'].dt.hour\n",
|
||||
"\n",
|
||||
"# Filter for active users and create a pivot table\n",
|
||||
"active_counts = df[df['was_active'] == True].pivot_table(index='name', columns='hour', values='was_active', aggfunc='sum', fill_value=0)\n",
|
||||
"active_counts['total_active_minutes'] = active_counts.sum(axis=1)\n",
|
||||
@@ -303,7 +307,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 64,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -342,6 +346,7 @@
|
||||
"plt.ylabel('Activity Count')\n",
|
||||
"plt.title('User Activity Throughout the Day')\n",
|
||||
"plt.legend(loc='upper left', bbox_to_anchor=(1, 1))\n",
|
||||
" pd.DataFrame: The processed DataFrame with additional columns for analysis.\n",
|
||||
"\n",
|
||||
"plt.grid(True)\n",
|
||||
"plt.show()\n"
|
||||
|
||||
Reference in New Issue
Block a user