Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CCC-Assignment2-Team69
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xinjie Lan
CCC-Assignment2-Team69
Commits
081ff0cd
Commit
081ff0cd
authored
6 years ago
by
xinjiel2
Browse files
Options
Downloads
Patches
Plain Diff
real time
parent
072d241a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
web_app_django/tweet/views.py
+74
-3
74 additions, 3 deletions
web_app_django/tweet/views.py
with
74 additions
and
3 deletions
web_app_django/tweet/views.py
+
74
−
3
View file @
081ff0cd
...
@@ -23,14 +23,85 @@ def index(request):
...
@@ -23,14 +23,85 @@ def index(request):
#GET /tweet_resutls/_design/city/_view/city-view HTTP/1.1
#GET /tweet_resutls/_design/city/_view/city-view HTTP/1.1
cityInfo
=
[]
cityInfo
=
[]
for
doc
in
docs
.
view
(
'
city/city-view
'
,
group
=
True
):
cityTotal
=
[]
cityPercentage
=
{}
for
doc
in
docs
.
view
(
'
results/result-view
'
,
group
=
True
):
print
(
doc
.
key
,
doc
.
value
)
print
(
doc
.
key
,
doc
.
value
)
cityInfo
.
append
(
doc
)
cityInfo
.
append
(
doc
)
print
(
cityInfo
)
for
doc
in
docs
.
view
(
'
results/cityTweet-view
'
,
group
=
True
):
#print(doc.key,doc.value)
#cityTotal.append(doc)
for
data
in
cityInfo
:
if
data
.
key
==
doc
.
key
:
number
=
(
data
.
value
/
doc
.
value
)
*
100
percentage
=
str
(
round
(
number
,
2
))
+
"
%
"
#print(percentage)
cityPercentage
[
data
.
key
]
=
percentage
#print(cityTotal)
#print(cityInfo)
context
=
cityPercentage
context
=
{
'
cityInfo
'
:
cityInfo
}
context
=
{
'
cityInfo
'
:
cityInfo
}
docsNsw
=
SERVER
[
'
aurin_nsw
'
]
#print(docs)
#print(docs.view('city/city-view',key = "melbourne"))
countId
=
[]
#print(docs['f6376ce946ac201c045408615e00d502'])
for
doc
in
docsNsw
:
features
=
docsNsw
[
doc
][
'
features
'
]
for
feature
in
features
:
countId
.
append
(
feature
[
"
id
"
])
print
(
len
(
countId
))
docsNswDomestic
=
SERVER
[
'
aurin_nsw_domestic
'
]
for
doc
in
docsNswDomestic
.
view
(
'
domesitc/new-view
'
):
for
element
in
doc
.
value
:
#print(doc.value[element])
countDomesitc
+=
doc
.
value
[
element
]
countDomesitc
+=
len
(
countId
)
print
(
countDomesitc
)
context
=
{
'
NswCount
'
:
countDomesitc
}
#print(docs[doc]['features'])
#GET /tweet_resutls/_design/city/_view/city-view HTTP/1.1
docsVic
=
SERVER
[
'
aurin_vic
'
]
att
=
[
'
a10
'
,
'
a20
'
,
'
a50
'
,
'
a80
'
]
count
=
0
for
doc
in
docsVic
.
view
(
'
vic/new-view
'
):
#print(doc.key, doc.value)
for
properties
in
doc
.
value
:
#print(properties)
for
element
in
properties
:
if
element
in
att
:
if
properties
[
element
]
==
'
lga_code_2011
'
:
continue
elif
properties
[
element
]
==
None
:
continue
else
:
count
+=
properties
[
element
]
print
(
count
)
context
=
{
'
VicCount
'
:
count
}
docsSa
=
SERVER
[
'
aurin_sa
'
]
countForSa
=
0
for
doc
in
docsSa
.
view
(
'
sa/new-view
'
):
for
properties
in
doc
.
value
:
for
element
in
properties
:
if
element
==
'
month
'
or
element
==
"
id
"
:
continue
else
:
if
not
properties
[
element
]
==
None
:
#print(countForSa)
countForSa
+=
properties
[
element
]
print
(
countForSa
)
context
=
{
'
SaCount
'
:
countForSa
}
#context = {'file':2}
#context = {'file':2}
else
:
else
:
context
=
{
'
file
'
:
error
}
context
=
{
'
file
'
:
error
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment