-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgos.gxml
executable file
·162 lines (107 loc) · 2.56 KB
/
gos.gxml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?xml version="1.0" encoding="UTF-8"?>
<gos>
<!-- xml docs : http://golangserver.com/docs/ -->
<deploy>webapp</deploy>
<port>5070</port>
<not_found>/your-404-page</not_found>
<error>/your-500-page</error>
<output>application.go</output>
<domain></domain><!-- Cookie domain -->
<main>
</main>
<key>a very very very very secret key</key>
<header>
<struct name="Choice">
Text string
Interests []string
Weight,Index int
</struct>
<struct name="Question">
Text string
Choices []Choice
Index int
</struct>
<struct name="Group">
Text string
Questions []Question
Resume string
</struct>
<struct name="Progress">
Text string
Score float64
</struct>
</header>
<methods>
<method name="ExtractTraits" var="" return="map[string]int">
var result = make(map[string]int)
var groups = GetGroups()
for _,g := range groups {
for _,q := range g.Questions {
for _, c := range q.Choices {
for _, s := range c.Interests {
_, ok := result[s]
if !ok {
result[s] = 0
}
}
}
}
}
return result
</method>
<method name="GetProgress" var="" return="[]Progress">
var ps []Progress
var r = args[0].(*http.Request)
query := r.URL.Query()
groups := GetGroups()
traits := ExtractTraits()
for _,g := range groups {
for _, q := range g.Questions {
i,err := strconv.Atoi(
query.Get(strconv.Itoa(q.Index)),
)
if err != nil {
fmt.Println(err)
continue
}
c := q.Choices[i]
for _, interest := range c.Interests {
traits[interest] += c.Weight
}
}
}
total := GetTotal(traits)
for k, v := range traits {
p := Progress{
Text : k,
Score : ( float64(v)/float64(total) ) * 100,
}
ps = append(ps, p)
}
fmt.Println("R", ps, traits, total)
return ps
</method>
<method name="GetGroups" var="" return="[]Group">
var groups []Group
var count = 0
for _,g := range globals.Groups {
for iQ, q := range g.Questions {
count++
g.Questions[iQ].Index = count
for iC,_ := range q.Choices {
g.Questions[iQ].Choices[iC].Index = iC
}
}
groups = append(groups, g)
}
return groups
</method>
</methods>
<templates>
<template name="hGroup" tmpl="group" struct="Group" />
<template name="hQuestion" tmpl="question" struct="Question" />
<template name="hProgress" tmpl="progress" struct="Progress" />
</templates>
<endpoints>
</endpoints>
</gos>