Преглед изворни кода

order by images results

develop
Robin Thoni пре 8 година
родитељ
комит
dee0281c4f
1 измењених фајлова са 48 додато и 47 уклоњено
  1. 48
    47
      sql/struct_init.sql

+ 48
- 47
sql/struct_init.sql Прегледај датотеку

@@ -43,6 +43,7 @@ CREATE FUNCTION sp_get_images(_only_mine boolean, _user_id_me integer, OUT id in
43 43
         SELECT i.id, i.name, i.user_id, i.date
44 44
         FROM images i
45 45
         WHERE (CASE WHEN _only_mine THEN i.user_id = _user_id_me ELSE TRUE END)
46
+        ORDER BY i.date DESC
46 47
 $$;
47 48
 
48 49
 
@@ -53,8 +54,8 @@ $$;
53 54
 
54 55
 CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
55 56
     LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
56
-    AS $$
57
-SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
57
+    AS $$
58
+SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
58 59
 $$;
59 60
 
60 61
 
@@ -65,11 +66,11 @@ $$;
65 66
 
66 67
 CREATE FUNCTION sp_lu_get_all_user_settings(_user_id integer, OUT _settings json) RETURNS SETOF json
67 68
     LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
68
-    AS $$
69
-	SELECT sp_lu_get_user_setting(_user_id, s.name)
70
-	FROM luticate_settings s
71
-	WHERE NOT s.is_admin
72
-	ORDER BY s.name
69
+    AS $$
70
+	SELECT sp_lu_get_user_setting(_user_id, s.name)
71
+	FROM luticate_settings s
72
+	WHERE NOT s.is_admin
73
+	ORDER BY s.name
73 74
 $$;
74 75
 
75 76
 
@@ -80,28 +81,28 @@ $$;
80 81
 
81 82
 CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
82 83
     LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
83
-    AS $$
84
-DECLARE
85
-    groups int[];
86
-    g INT;
87
-BEGIN
88
-    SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
89
-    IF val is null THEN
90
-        SELECT lpg."value" into val FROM luticate_permissions_groups lpg
91
-            INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
92
-            INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
93
-        WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
94
-        IF val is null then
95
-            SELECT lpg."value" into val FROM luticate_permissions_groups lpg
96
-                INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
97
-                INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
98
-            WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
99
-            IF val is null then
100
-                SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
101
-            END IF;
102
-        end if;
103
-    END IF;
104
-END;
84
+    AS $$
85
+DECLARE
86
+    groups int[];
87
+    g INT;
88
+BEGIN
89
+    SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
90
+    IF val is null THEN
91
+        SELECT lpg."value" into val FROM luticate_permissions_groups lpg
92
+            INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
93
+            INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
94
+        WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
95
+        IF val is null then
96
+            SELECT lpg."value" into val FROM luticate_permissions_groups lpg
97
+                INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
98
+                INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
99
+            WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
100
+            IF val is null then
101
+                SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
102
+            END IF;
103
+        end if;
104
+    END IF;
105
+END;
105 106
 $$;
106 107
 
107 108
 
@@ -112,24 +113,24 @@ $$;
112 113
 
113 114
 CREATE FUNCTION sp_lu_get_user_setting(_user_id integer, _setting_name character varying, OUT setting json) RETURNS json
114 115
     LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
115
-    AS $$
116
-DECLARE
117
-_setting luticate_settings;
118
-_setting_user luticate_settings_users;
119
-BEGIN
120
-    SELECT * INTO _setting FROM luticate_settings WHERE "name" = _setting_name AND NOT "is_admin";
121
-    IF _setting IS NULL THEN
122
-        setting := NULL;
123
-    ELSE
124
-        IF NOT _setting.is_blocked THEN
125
-            SELECT * INTO _setting_user FROM luticate_settings_users WHERE "user_id" = _user_id AND "name" = _setting_name;
126
-            IF _setting_user IS NOT NULL THEN
127
-                _setting.value := _setting_user.value;
128
-            END IF;
129
-        END IF;
130
-        setting := to_json(_setting);
131
-    END IF;
132
-END;
116
+    AS $$
117
+DECLARE
118
+_setting luticate_settings;
119
+_setting_user luticate_settings_users;
120
+BEGIN
121
+    SELECT * INTO _setting FROM luticate_settings WHERE "name" = _setting_name AND NOT "is_admin";
122
+    IF _setting IS NULL THEN
123
+        setting := NULL;
124
+    ELSE
125
+        IF NOT _setting.is_blocked THEN
126
+            SELECT * INTO _setting_user FROM luticate_settings_users WHERE "user_id" = _user_id AND "name" = _setting_name;
127
+            IF _setting_user IS NOT NULL THEN
128
+                _setting.value := _setting_user.value;
129
+            END IF;
130
+        END IF;
131
+        setting := to_json(_setting);
132
+    END IF;
133
+END;
133 134
 $$;
134 135
 
135 136
 

Loading…
Откажи
Сачувај