Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unstable
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
PROINFODATA
unstable
Commits
905f6588
Commit
905f6588
authored
11 years ago
by
Eduardo L. Buratti
Browse files
Options
Downloads
Patches
Plain Diff
database: Fix operating systems output order
Signed-off-by:
Eduardo L. Buratti
<
elb09@c3sl.ufpr.br
>
parent
6e7ecd4c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
database/query/os.sql
+22
-20
22 additions, 20 deletions
database/query/os.sql
with
22 additions
and
20 deletions
database/query/os.sql
+
22
−
20
View file @
905f6588
...
...
@@ -6,7 +6,7 @@ AS $$
WHEN
'Debian GNU/Linux 4.0'
THEN
'Debian'
WHEN
'Debian GNU/Linux 6.0'
THEN
'Debian'
WHEN
'Kernel'
THEN
'Outros'
WHEN
'Linux Educacional'
THEN
'Linux Educacional
1
.0'
WHEN
'Linux Educacional'
THEN
'Linux Educacional
3
.0'
WHEN
'Linux Educacional 2.0'
THEN
'Linux Educacional 2.0'
WHEN
'Linux Educacional 3.0'
THEN
'Linux Educacional 3.0'
WHEN
'Linux Educacional 4.0'
THEN
'Linux Educacional 4.0'
...
...
@@ -46,37 +46,39 @@ CREATE OR REPLACE FUNCTION os_brazil(proj project_enum, b_date DATE DEFAULT CURR
TABLE
(
os_distro
text
,
total
bigint
)
AS
$$
BEGIN
CREATE
TEMP
TABLE
temp_os_categories
(
category
text
)
ON
COMMIT
DROP
;
INSERT
INTO
temp_os_categories
(
category
)
VALUES
(
'Debian'
),
(
'Linux Educacional 1.0'
),
(
'Linux Educacional 2.0'
),
(
'Linux Educacional 3.0'
),
(
'Linux Educacional 4.0'
),
(
'Linux Educacional 5.0'
),
(
'Outros'
),
(
'Ubuntu'
),
(
'Windows 7'
),
(
'Windows MultiPoint Server'
);
CREATE
TEMP
TABLE
temp_os_categories
(
ord
integer
,
category
text
)
ON
COMMIT
DROP
;
INSERT
INTO
temp_os_categories
(
ord
,
category
)
VALUES
(
0
,
'Linux Educacional 5.0'
),
(
1
,
'Linux Educacional 4.0'
),
(
2
,
'Linux Educacional 3.0'
),
(
3
,
'Linux Educacional 2.0'
),
(
4
,
'Windows 7'
),
(
5
,
'Windows MultiPoint Server'
),
(
6
,
'Ubuntu'
),
(
7
,
'Debian'
),
(
8
,
'Outros'
);
RETURN
QUERY
SELECT
os
,
sum
(
c
)::
bigint
FROM
(
(
SELECT
s
.
os
AS
os
,
count
(
s
.
os
)
AS
c
(
SELECT
tmp
.
ord
AS
ord
,
s
.
os
AS
os
,
count
(
s
.
os
)
AS
c
FROM
(
SELECT
os_categorize
(
max
(
inv
.
os_distro
))
AS
os
FROM
dim_inventory
inv
WHERE
inv
.
project
=
proj
AND
inv
.
load_date
<=
b_date
GROUP
BY
inv
.
sch_id
,
inv
.
macaddr
)
AS
s
GROUP
BY
s
.
os
ORDER
BY
count
(
s
.
os
)
)
s
,
temp_os_categories
tmp
WHERE
tmp
.
category
=
s
.
os
GROUP
BY
tmp
.
ord
,
s
.
os
)
UNION
ALL
(
SELECT
category
AS
os
,
0
::
bigint
AS
c
(
SELECT
ord
,
category
AS
os
,
0
::
bigint
AS
c
FROM
temp_os_categories
)
)
uni
GROUP
BY
os
;
GROUP
BY
ord
,
os
ORDER
BY
ord
;
DROP
TABLE
IF
EXISTS
temp_os_categories
;
END
;
$$
LANGUAGE
plpgsql
;
...
...
@@ -102,6 +104,6 @@ AS $$
UNION
SELECT
current_date
)
dates
)
a
ORDER
BY
gen_date
,(
os_brazil
).
total
;
gen_date
;
$$
LANGUAGE
SQL
;
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