File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed
Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 11[project ]
22name = " ssb-dash-framework"
3- version = " 0.1.4a1 "
3+ version = " 0.1.4a2 "
44description = " SSB Dash Framework"
55authors = [{ name = " Magnus Theodor Engh" , email = " dor@ssb.no" }]
66license = " GPL-3.0"
Original file line number Diff line number Diff line change 5959from .utils import enable_app_logging
6060from .utils import module_validator
6161from .utils import sidebar_button
62+ from .utils import apply_edits
6263
6364# from .modals import HBMethod
6465# from .utils import _get_kostra_r
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def __init__(
109109 self .module_layout = self ._create_layout ()
110110 self .module_callbacks ()
111111 self ._is_valid ()
112- self .timestamp = int ( time . time () * 1000 )
112+ self .tz = zoneinfo . ZoneInfo ( "Europe/Oslo" )
113113 module_validator (self )
114114
115115 def _is_valid (self ) -> None :
@@ -414,8 +414,6 @@ def confirm_edit(
414414 edit_with_reason ["user" ] = self .user
415415 edit_with_reason ["change_event" ] = "manual"
416416
417- # Create timestamp that can be compared with datetime.now() running from users IDE
418- tz = zoneinfo .ZoneInfo ("Europe/Oslo" )
419417 aware_timestamp = datetime .now (tz ) # timezone-aware
420418 naive_timestamp = aware_timestamp .replace (tzinfo = None ) # drop tzinfo
421419 edit_with_reason ["timestamp" ] = naive_timestamp
@@ -506,7 +504,10 @@ def immediate_edit(
506504 if not edited :
507505 raise PreventUpdate
508506 edit = edited [0 ]
509- edit ["timestamp" ] = int (time .time () * 1000 )
507+
508+ aware_timestamp = datetime .now (self .tz ) # timezone-aware
509+ naive_timestamp = aware_timestamp .replace (tzinfo = None ) # drop tzinfo
510+ edit ["timestamp" ] = naive_timestamp
510511 if self .log_filepath :
511512 with open (self .log_filepath , "a" , encoding = "utf-8" ) as f :
512513 f .write (
Original file line number Diff line number Diff line change 11import datetime
2-
32import pandas as pd
3+ import warnings
44
55
66def apply_edits (
@@ -39,6 +39,7 @@ def apply_edits(
3939 - Rows in `df` without matching uuids remain unchanged.
4040 - This function does not modify `df` in place; it returns an edited copy.
4141 """
42+
4243 df_edited = df .copy ()
4344 log = pd .read_json (filepath_log , lines = True )
4445 log = log .loc [log ["timestamp" ] > app_timestamp ].copy ()
@@ -63,9 +64,10 @@ def apply_edits(
6364 ]
6465
6566 mapping = mapping [~ mapping .index .duplicated (keep = "last" )]
66-
67- df_edited .loc [df_edited ["uuid" ].isin (mapping .index ), col ] = (
68- df_edited ["uuid" ].map (mapping ).fillna (df_edited [col ])
69- )
67+ with warnings .catch_warnings ():
68+ warnings .simplefilter ("ignore" , category = FutureWarning )
69+ df_edited .loc [df_edited ["uuid" ].isin (mapping .index ), col ] = (
70+ df_edited ["uuid" ].map (mapping ).fillna (df_edited [col ])
71+ )
7072
7173 return df_edited
You can’t perform that action at this time.
0 commit comments