Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장연우
/
WELLO
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
soonmyeong2
2019-11-19 22:53:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
458b97d63c20b4f02946acedf6b934fe82572656
458b97d6
1 parent
bb2ff6c9
make view_counter
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
1 deletions
.gitignore
view_count_raw.json
view_counter.py
.gitignore
View file @
458b97d
wello_firebase_SDKKey.json
__pycache__
\ No newline at end of file
__pycache__
vip_key.jks
\ No newline at end of file
...
...
view_count_raw.json
View file @
458b97d
{
"0"
:
{
"2019-11-19"
:
14
},
"1"
:
{
"2019-11-19"
:
3
},
"2"
:
{
"2019-11-19"
:
13
},
"3"
:
{
"2019-11-19"
:
4
},
"4"
:
{
"2019-11-19"
:
3
},
"5"
:
{
"2019-11-19"
:
4
},
"6"
:
{
"2019-11-19"
:
6
},
"7"
:
{
"2019-11-19"
:
3
},
"8"
:
{
"2019-11-19"
:
4
},
"9"
:
{
"2019-11-19"
:
11
}
}
\ No newline at end of file
...
...
view_counter.py
0 → 100644
View file @
458b97d
from
firebase_admin
import
db
from
firebase_admin
import
credentials
import
firebase_admin
import
json
from
datetime
import
datetime
cred
=
credentials
.
Certificate
(
'wello_firebase_SDKKey.json'
)
firebase_admin
.
initialize_app
(
cred
,
{
'databaseURL'
:
'https://capstone-vip.firebaseio.com/'
})
ref
=
db
.
reference
()
policies
=
ref
.
get
()
## compare dict
json_data
=
dict
()
today
=
str
(
datetime
.
now
()
.
year
)
+
"-"
+
str
(
datetime
.
now
()
.
month
)
+
"-"
+
str
(
datetime
.
now
()
.
day
)
def
view_count_raw_writer
():
with
open
(
'./view_count_raw.json'
,
'w'
,
encoding
=
'utf-8'
)
as
make_file
:
json
.
dump
(
json_data
,
make_file
,
indent
=
"
\t
"
)
def
count_update
():
for
policy
in
policies
:
if
policy
[
"Value"
]
in
json_data
.
keys
():
if
policy
[
"Value"
][
datetime
.
now
()]
in
json_data
[
"Value"
]
.
keys
():
json_data
[
policy
[
"Value"
]][
today
]
=
abs
(
policy
[
"View"
])
else
:
json_data
[
policy
[
"Value"
]][
today
]
=
dict
()
json_data
[
policy
[
"Value"
]][
today
]
=
abs
(
policy
[
"View"
])
else
:
json_data
[
policy
[
"Value"
]]
=
dict
()
json_data
[
policy
[
"Value"
]][
today
]
=
abs
(
policy
[
"View"
])
def
view_count_raw_reader
():
with
open
(
'./view_count_raw.json'
,
'r'
,
encoding
=
'utf-8'
)
as
json_file
:
json_data
=
json
.
load
(
json_file
)
view_count_raw_reader
()
count_update
()
print
(
json
.
dumps
(
json_data
,
indent
=
"
\t
"
))
view_count_raw_writer
()
Please
register
or
login
to post a comment