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-18 22:29:24 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4424d5cdc0a3ee016907d3725c65cb0d574b6c0b
4424d5cd
1 parent
f58d6ab4
make auto date_calculate file
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
12 deletions
.gitignore
D_dayCalculator.py
db_updater.py
calculate_Dday.py → raw_calculate_Dday.py
view_count_raw.json
vip/app/src/main/java/com/example/vip/DetailActivity.kt
vip/app/src/main/res/layout/activity_detail.xml
.gitignore
View file @
4424d5c
wello_firebase_SDKKey.json
\ No newline at end of file
wello_firebase_SDKKey.json
__pycache__
\ No newline at end of file
...
...
D_dayCalculator.py
0 → 100644
View file @
4424d5c
#-*- coding: utf-8 -*-
from
datetime
import
datetime
,
timedelta
import
re
class
D_day
:
def
__init__
(
self
,
date_str
):
self
.
date
=
date_str
def
dday_calculate
(
self
,
date
):
y_m_d
=
date
.
split
(
"-"
)
return
(
datetime
.
now
()
-
datetime
(
int
(
y_m_d
[
0
]),
int
(
y_m_d
[
1
]),
int
(
y_m_d
[
2
])))
.
days
def
date_calculate
(
self
):
dates
=
re
.
findall
(
r'[0-9]{2,4}[.|-][0-9]{1,2}[.|-][0-9]{1,2}|~'
,
self
.
date
)
for
i
in
range
(
len
(
dates
)):
dates
[
i
]
=
dates
[
i
]
.
replace
(
"."
,
"-"
)
# 날짜가 없는 경우
if
len
(
dates
)
==
0
:
return
"상시"
# XXX ~
if
dates
[
-
1
]
==
"~"
:
dday
=
self
.
dday_calculate
(
dates
[
0
])
if
dday
>
0
:
return
"진행중"
else
:
return
"준비중"
# ~ XXX and XXX ~ XXX
if
dates
[
-
1
]
!=
"~"
:
dday
=
self
.
dday_calculate
(
dates
[
-
1
])
if
dday
<
0
:
return
"D"
+
str
(
dday
)
else
:
return
"종료"
# except
return
"상 시"
def
update_date
(
self
,
date
):
self
.
date
=
date
#### example
'''
a=D_day("2019.11.20")
print(a.date_calculate())
a.update_date("2019.11.21")
print(a.date_calculate())
a.update_date("~2019.11.30")
print(a.date_calculate())
a.update_date("2019.10.11~2019.11.27")
print(a.date_calculate())
a.update_date("2019.10.11~")
print(a.date_calculate())
'''
db_updater.py
0 → 100644
View file @
4424d5c
from
firebase_admin
import
db
from
firebase_admin
import
credentials
import
firebase_admin
from
D_dayCalculator
import
D_day
import
json
cred
=
credentials
.
Certificate
(
'wello_firebase_SDKKey.json'
)
firebase_admin
.
initialize_app
(
cred
,
{
'databaseURL'
:
'https://wello-pocliy-temp.firebaseio.com/'
})
ref
=
db
.
reference
()
policies
=
ref
.
get
()
date
=
D_day
(
"1970.01.01"
)
with
open
(
'view_count_raw.json'
,
'rt'
,
encoding
=
'utf-8'
)
as
json_file
:
view_count
=
json
.
load
(
json_file
)
for
policy
in
policies
:
# 날짜 갱신
date
.
update_date
(
policy
[
"Date"
])
print
(
date
.
date_calculate
())
ref
.
child
(
policy
[
"Value"
])
.
child
(
"D_day"
)
.
set
(
date
.
date_calculate
())
calculate_Dday.py
→
raw_
calculate_Dday.py
View file @
4424d5c
...
...
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
import
json
import
re
'''
def
dday_calculate
(
date
):
y_m_d
=
date
.
split
(
"-"
)
return
(
datetime
.
now
()
-
datetime
(
int
(
y_m_d
[
0
]),
int
(
y_m_d
[
1
]),
int
(
y_m_d
[
2
])))
.
days
...
...
@@ -37,7 +37,7 @@ def date_calculate(url):
# except
return
"상 시"
'''
with
open
(
'd.json'
,
'rt'
,
encoding
=
'utf-8'
)
as
json_file
:
...
...
@@ -50,14 +50,16 @@ for js in json_data:
js
[
key
]
=
str
(
value
)
if
key
==
"Link"
and
value
[
0
]
==
'['
:
js
[
key
]
=
value
[
1
:
-
1
]
# if key == "Date":
# js[key] = date_calculate(value)
# critical point
if
key
==
"View"
:
js
[
"D_day"
]
=
date_calculate
(
js
[
"Date"
])
break
###############
with
open
(
'result.json'
,
'w'
,
encoding
=
'utf-8'
)
as
make_file
:
make_file
.
write
(
'['
)
for
i
,
js
in
enumerate
(
json_data
):
#make_file.write(json.dumps(js, indent="\t",ensure_ascii=False))
json
.
dump
(
js
,
make_file
,
indent
=
"
\t
"
,
ensure_ascii
=
False
)
if
i
!=
len
(
json_data
)
-
1
:
make_file
.
write
(
','
)
...
...
view_count_raw.json
0 → 100644
View file @
4424d5c
File mode changed
vip/app/src/main/java/com/example/vip/DetailActivity.kt
View file @
4424d5c
...
...
@@ -42,7 +42,8 @@ data class MemoItemDetail(
val
Keyword
:
String
=
""
,
val
Content
:
String
=
""
,
val
Link
:
String
=
""
,
val
Date
:
String
=
"상시"
val
Date
:
String
=
"상시"
,
val
D_day
:
String
=
""
)
class
DetailActivity
:
AppCompatActivity
()
{
...
...
@@ -75,7 +76,7 @@ class DetailActivity : AppCompatActivity() {
var
detailFavor
:
TextView
=
findViewById
(
R
.
id
.
policyFavorDetail
)
detailImage
.
setImageResource
(
R
.
drawable
.
image01
)
detailDday
.
text
=
memo
!!
.
D
ate
detailDday
.
text
=
memo
!!
.
D
_day
detailTitle
.
text
=
memo
!!
.
Policy
detailScore
.
rating
=
4
.
toFloat
()
detailFavor
.
text
=
" "
+
memo
!!
.
Keyword
...
...
vip/app/src/main/res/layout/activity_detail.xml
View file @
4424d5c
...
...
@@ -79,9 +79,8 @@
android:id=
"@+id/policyFavorDetail"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:layout_marginTop=
"5dp"
android:ellipsize=
"end"
android:text=
"TextView"
/>
<TextView
...
...
@@ -109,7 +108,8 @@
<WebView
android:id=
"@+id/policy_context"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
...
...
Please
register
or
login
to post a comment