Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
fd7c3652
Commit
fd7c3652
authored
Feb 13, 2018
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the same function for both history orders
parent
fd9c7139
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
34 deletions
+16
-34
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+1
-1
src/database/database.cpp
src/database/database.cpp
+13
-27
src/database/database.hpp
src/database/database.hpp
+2
-6
No files found.
src/bridge/bridge.cpp
View file @
fd7c3652
...
...
@@ -1020,7 +1020,7 @@ void Bridge::send_room_history(const std::string& hostname, std::string chan_nam
auto
limit
=
coptions
.
col
<
Database
::
MaxHistoryLength
>
();
if
(
history_limit
.
stanzas
>=
0
&&
history_limit
.
stanzas
<
limit
)
limit
=
history_limit
.
stanzas
;
const
auto
lines
=
Database
::
get_muc_
most_recent_logs
(
this
->
user_jid
,
chan_name
,
hostname
,
limit
,
history_limit
.
since
);
const
auto
lines
=
Database
::
get_muc_
logs
(
this
->
user_jid
,
chan_name
,
hostname
,
limit
,
history_limit
.
since
,
{},
Id
::
unset_value
,
Database
::
Paging
::
last
);
chan_name
.
append
(
utils
::
empty_if_fixed_server
(
"%"
+
hostname
));
for
(
const
auto
&
line
:
lines
)
{
...
...
src/database/database.cpp
View file @
fd7c3652
...
...
@@ -165,8 +165,11 @@ std::string Database::store_muc_message(const std::string& owner, const std::str
}
std
::
vector
<
Database
::
MucLogLine
>
Database
::
get_muc_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
,
const
std
::
string
&
start
,
const
std
::
string
&
end
,
const
Id
::
real_type
after_id
)
int
limit
,
const
std
::
string
&
start
,
const
std
::
string
&
end
,
const
Id
::
real_type
after_id
,
Database
::
Paging
paging
)
{
if
(
limit
==
0
)
return
{};
auto
request
=
Database
::
muc_log_lines
.
select
();
request
.
where
()
<<
Database
::
Owner
{}
<<
"="
<<
owner
<<
\
" and "
<<
Database
::
IrcChanName
{}
<<
"="
<<
chan_name
<<
\
...
...
@@ -189,37 +192,20 @@ std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owne
request
<<
" and "
<<
Id
{}
<<
">"
<<
after_id
;
}
if
(
limit
>=
0
)
request
.
limit
()
<<
limit
;
auto
result
=
request
.
execute
(
*
Database
::
db
);
return
{
result
.
cbegin
(),
result
.
cend
()};
}
std
::
vector
<
Database
::
MucLogLine
>
Database
::
get_muc_most_recent_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
,
const
std
::
string
&
start
)
{
auto
request
=
Database
::
muc_log_lines
.
select
();
request
.
where
()
<<
Database
::
Owner
{}
<<
"="
<<
owner
<<
\
" and "
<<
Database
::
IrcChanName
{}
<<
"="
<<
chan_name
<<
\
" and "
<<
Database
::
IrcServerName
{}
<<
"="
<<
server
;
if
(
!
start
.
empty
())
{
const
auto
start_time
=
utils
::
parse_datetime
(
start
);
if
(
start_time
!=
-
1
)
request
<<
" and "
<<
Database
::
Date
{}
<<
">="
<<
start_time
;
}
request
.
order_by
()
<<
Id
{}
<<
" DESC "
;
if
(
paging
==
Database
::
Paging
::
first
)
request
.
order_by
()
<<
Id
{}
<<
" ASC "
;
else
request
.
order_by
()
<<
Id
{}
<<
" DESC "
;
if
(
limit
>=
0
)
request
.
limit
()
<<
limit
;
auto
result
=
request
.
execute
(
*
Database
::
db
);
return
{
result
.
crbegin
(),
result
.
crend
()};
if
(
paging
==
Database
::
Paging
::
first
)
return
result
;
else
return
{
result
.
crbegin
(),
result
.
crend
()};
}
Database
::
MucLogLine
Database
::
get_muc_log
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
...
...
src/database/database.hpp
View file @
fd7c3652
...
...
@@ -23,6 +23,7 @@ class Database
public:
using
time_point
=
std
::
chrono
::
system_clock
::
time_point
;
struct
RecordNotFound
:
public
std
::
exception
{};
enum
class
Paging
{
first
,
last
};
struct
Uuid
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"uuid_"
;
};
...
...
@@ -125,13 +126,8 @@ class Database
*/
static
std
::
vector
<
MucLogLine
>
get_muc_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
=-
1
,
const
std
::
string
&
start
=
""
,
const
std
::
string
&
end
=
""
,
const
Id
::
real_type
after_id
=
Id
::
unset_value
);
const
Id
::
real_type
after_id
=
Id
::
unset_value
,
Paging
=
Paging
::
first
);
/**
* Get the most recent messages from the archive, with optional limit and start date
*/
static
std
::
vector
<
MucLogLine
>
get_muc_most_recent_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
=-
1
,
const
std
::
string
&
start
=
""
);
/**
* Get just one single record matching the given uuid, between (optional) end and start.
* If it does not exist (or is not between end and start), throw a RecordNotFound exception.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment